var x_a=new Array();
var y_a=new Array();
var x_b=new Array();
var y_b=new Array();
var life_a=new Array();
var life_b=new Array();
var mode;
function sample(){
var timer;
var delay = 1000;
mode=2;
faststep();
var loop = function(){
m1=mode;
if(m1==1)mode=2;
if(m1==2)mode=1;
if(mode==1)move_a();
if(mode==2)move_b();
paint();
clearTimeout(timer);
timer = setTimeout(loop,delay);
}
loop();
}
function faststep(){
for(s=1;s<10;s++){
x_a[s]=s;
y_a[s]=1;
x_b[s]=s;
y_b[s]=9;
life_a[s]=100;
life_b[s]=100;
}
}
function move_a(){
n1=9*Math.random();
n2=Math.floor(n1)+1;
y_a[n2]=y_a[n2]+1;
}
function move_b(){
n1=9*Math.random();
n2=Math.floor(n1)+1;
y_b[n2]=y_b[n2]-1;
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
for(s=1;s<10;s++){
str=str+sub.rect(50*x_a[s]
,50*y_a[s],50,50,"red");
str=str+sub.rect(50*x_b[s]
,50*y_b[s],50,50,"blue");
}
str=str+"</svg>";
$("#memo").html(str);
}
最終更新:2015年03月01日 13:25