アットウィキロゴ

anime98

var x = new Array();
var y = new Array();
var dir = new Array();
var number_dir = new Array();
var ball;
 
 
function sample() {
 
 
 
    tx = 0;
for(s=1;s<6;s++){
for(sx=1;sx<6;sx++){
    tx = tx + 1;
    x[tx] = s;
    y[tx] = sx;    
}}
 
for(t=1;t<26;t++){
    tx = 0;
dir[t] = new Array();
for(s1=-1;s1<2;s1++){
for(s2=-1;s2<2;s2++){
    x1 = x[t] + s1;
    y1 = y[t] + s2;
    sx = search(x1, y1);
  if(sx==t)sx=0;
    if (sx > 0) tx = tx + 1;
    if (sx > 0) dir[t][tx] = sx;
}}
number_dir[t] = tx;
}
 
ball = 1;
 
var timer;
var delay = 1000;
 
 
var loop = function () {
 
    move();
 
    paint();
 
    clearTimeout(timer);
    timer = setTimeout(loop, delay);
}
 
loop();
 
 
} 
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
for(t=1;t<26;t++){
str=str+sub.rect(100*x[t]-100,100*y[t]-100,100,100,"red");   
}
str=str+sub.rect(100*x[ball]-100,100*y[ball]-100,100,100,"blue");   
 
str=str+"</svg>";
 
$("#memo").html(str);
 
}
 
 
function move(){
 
    var n1 = number_dir[ball] * Math.random();
    var n2 = Math.floor(n1) + 1;
    ball = dir[ball][n2];
 
}
 
 
function search(x1,y1){
 
    var s,sx,h;
    sx=0;
    for (s = 1; s < 26; s++) {
        h = 0;
        if (x[s] == x1) h = h + 1;
        if (y[s] == y1) h = h + 1;
        if (h == 2) sx = s;
    }
    return sx;
 
}
 
最終更新:2015年06月14日 16:05