var bx,by,ball;
function sample(){
var timer;
var delay = 1000;
bx=5;
by=1;
ball=1;
var loop = function(){
move();
bomb();
if(ball==3)bx=5;
if(ball==3)by=1;
if(ball==3)ball=1;
if(by>9)bx=5;
if(by>9)ball=1;
if(by>9)by=1;
paint();
clearTimeout(timer);
timer = setTimeout(loop,delay);
}
loop();
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
str=str+sub.rect(50*bx,50*by,50,50,"blue");
if(ball>1)str=str+sub.rect(50*bx,50*by,50,50,"red");
str=str+"</svg>";
$("#memo").html(str);
}
function move(){
dx=0;
if(Math.random()>0.9)dx=1;
if(Math.random()>0.9)dx=-1;
bx=bx+dx;
by=by+1;
}
function bomb(){
if(ball==2)ball=3;
h=0;
if(Math.random()>0.9)h=h+1;
if(ball==1)h=h+1;
if(h==2)ball=2;
}
最終更新:2015年05月04日 10:02