アットウィキロゴ

perrtyu

var ball=new Array();
var bx=new Array();
var by=new Array();
var route=new Array(); 
var ban=new Array(); 
 
function sample(){
 
mode=1;
 
for(s=1;s<101;s++){
route[s]=new Array();
ban[s]=new Array();
}
 
 
 
for(s=1;s<101;s++){
for(sx=1;sx<101;sx++){
route[s][sx]=0;
ban[s][sx]=0;
}}
 
 
for(s=30;s<71;s++){
for(sx=30;sx<71;sx++){
ban[s][sx]=100;
}}
 
 
for(sx=45;sx<56;sx++){ 
route[100][sx]=100;
}
 
for(t=1;t<100;t++){
s=100-t;
for(sx=1;sx<101;sx++){
h=0;
for(tx=-1;tx<2;tx++){
s1=sx+tx;
if(s1>100)s1=100;
if(s1<1)s1=1;
if(route[s+1][s1]>50)h=100;
}
if(ban[s][sx]>50)h=0;
if(h>50)route[s][sx]=100;
}
}
 
 
for(s=1;s<101;s++){
ball[s]=0;
bx[s]=1;
by[s]=50;
}
 
 
 
 
 
 
var timer;
var delay = 100;
 
var loop = function () {
 
 
if(Math.random()>0.9)gun();
 
 for(s=1;s<101;s++){
if(ball[s]>50)move(s);
 }
 
for(s=1;s<101;s++){
if(by[s]>99)ball[s]=0;
}
 
 
if(mode==2)mode=1;
 
for(s=1;s<101;s++){
h=0;
if(by[s]<90)h=h+1;
if(by[s]>80)h=h+1;
if(bx[s]>30)h=h+1;
if(bx[s]<70)h=h+1;
if(h==4)mode=2;
}
 
 
 
paint();
 
    clearTimeout(timer);
    timer = setTimeout(loop, delay);
}
 
loop();
 
 
 
 
}
 
function move(s){
 
by[s]=by[s]+1;
 
var a=new Array();
 
tx=0;
for(sx=-1;sx<2;sx++){
x1=bx[s]+sx;
if(x1<1)x1=1;
if(x1>100)x1=100;
y1=by[s];
if(route[y1][x1]>50)tx=tx+1;
if(route[y1][x1]>50)a[tx]=x1;
}
 
m1=tx*Math.random();
m2=Math.floor(m1)+1;
m3=a[m2];
 
bx[s]=m3;
 
} 
 
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
str=str+sub.rect(0,0,500,500,"blue");
if(mode==1)str=str+sub.rect(150,150,200,200,"pink");
if(mode==2)str=str+sub.rect(150,150,200,200,"green");
 
for(s=1;s<101;s++){    
if(ball[s]>50)str=str+sub.circle(5*bx[s],5*by[s],5,"red");
}  
 
 
str=str+"</svg>";
 
 
$("#memo").html(str);   
 
}
 
function gun(){
 
sx=0;
for(s=1;s<101;s++){
if(ball[s]<50)sx=s;    
}
 
ball[sx]=100;
bx[sx]=50;
by[sx]=1;
 
 
}
 
 
<!DOCTYPE html>
<html lang="ja">
    <head>
        <meta charset="utf-8" />
        <script src="sample.js"></script>
        <script src="jquery.js"></script>
<script src="svgpaint.js"></script>
        <title>パチンコ</title>
    </head>
    <body onload="sample()">
   <p id="memo"></p>
   </body>
</html>
 
最終更新:2016年09月15日 16:42