アットウィキロゴ

s2766

var a,b,ma,mb;
var x=new Array();
var y=new Array();
var c=new Array();
 
function sample(){
 
ma=200;
mb=200;
 
tx=0;
for(s=1;s<11;s++){
for(sx=1;sx<11;sx++){
tx=tx+1;
y[tx]=s;
x[tx]=sx;   
c[tx]=0;
}    
}
 
 
var timer;
var delay = 1000;
 
 a=1;
 b=1;
 
var loop = function () {
 
n1=10*Math.random();
n2=Math.floor(n1)+1;
a=a+n2;
 
if(a>100)a=a-100;
 if(c[a]==0)ma=ma-5;
if(c[a]==0)c[a]=1;
if(c[a]==2)ma=ma-1;
if(c[a]==2)mb=mb+1;
 
n1=10*Math.random();
n2=Math.floor(n1)+1;
b=b+n2;
 
if(b>100)b=b-100;
if(c[b]==0)mb=mb-5;
if(c[b]==0)c[b]=2;
if(c[b]==1)mb=mb-1;
if(c[b]==1)ma=ma+1;
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
str=str+sub.rect(0,0,500,500,"green");
for(s=1;s<101;s++){    
if(c[s]==1)str=str+sub.rect(50*x[s]-50,50*y[s]-50,50,50,"red");
if(c[s]==2)str=str+sub.rect(50*x[s]-50,50*y[s]-50,50,50,"blue");
} 
 
str=str+"</svg>";
 
$("#memo").html(str);   
 
$("#point").html(ma+","+mb)
 
if(ma<0)fresh();
if(mb<0)fresh();
 
 
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
 
loop();
 
 
 
 
 
}
 
function fresh(){
 
 
ma=200;
mb=200;
 
a=1;
b=1;
 
for(s=1;s<101;s++){
    c[s]=0;
    }
 
 
} 
 
最終更新:2015年12月12日 16:11