アットウィキロゴ

patinko

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>パチンコ</title>
<script src="sample.js"></script>
<script src="jquery.js"></script>
<script src="svgpaint.js"></script>
</head>
<body onload="sample()">
<p id="memo"></p> 
 <input id="but" type="button" value="ハンドル" />
</body>
</html>
 
 
 
var ball = new Array();
var bx = new Array();
var by = new Array();
var dx = new Array();
var dy = new Array();
 
var number;
var nx = new Array();
var ny = new Array();
 
function sample(){
 
 number = 100;
 
for(s=1;s<101;s++){
nx[s]=10*randx();
ny[s]=10*randx();
}
 
 
for(s=1;s<101;s++){
bx[s]=0;
by[s]=0;
dx[s]=0;
dy[s]=0;
ball[s]=0;    
}
 
$("#but").click(function () {
 strike();
});
 
var timer;
var delay = 100;
 
var loop = function () {
 
    move();
 
    wall();
 
    de();
 
    paint();
 
    clearTimeout(timer);
    timer = setTimeout(loop, delay);
}
 
loop();
 
 
 
 
}
 
function strike(){
 
 
    sx = 0;
for(s=1;s<101;s++){
if(ball[s]<50)sx=s;    
}
 
if (sx > 0) bx[sx] = 500;
if (sx > 0) by[sx] = 1000;
if (sx > 0) ball[sx] = 100;
if (sx > 0) dx[sx] =randx();
if (sx > 0) dy[sx] =0;
 
}
 
function de(){
 
for(s=1;s<101;s++){
h = 0;
if (by[s] < 10) h = h + 1;
if (ball[s] >50) h = h + 1;
if (h == 2) ball[s] = 0;
}
 
 
}
 
function wall() {
 
for(s=1;s<101;s++){
    h = 0;
if(bx[s]>990)h=h+1;    
if(dx[s]>0)h=h+1;
if (h == 2) dx[s] = -dx[s];
h = 0;
if(bx[s]<10)h=h+1;    
if(dx[s]<0)h=h+1;
if (h == 2) dx[s] = -dx[s];
}
 
 
}
 
 
 
 
function move(){
 
    g = 1;
 
for(s=1;s<101;s++){
dy[s] = dy[s] - g;
}  
 
for(s=1;s<101;s++){
bx[s]=bx[s]+dx[s];
by[s] = by[s] + dy[s];
}
 
 
 
 
}
 
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
str=str+sub.rect(5,5,500,500,"blue"); 
for(s=1;s<101;s++){    
if(ball[s]>50)str=str+sub.circle(5*bx[s]/10,500-5*by[s]/10,5,"red");
}
 
 
str=str+"</svg>";
 
$("#memo").html(str);   
 
}
 
 
function randx(){
 
n1=10*Math.random();
n2=Math.floor(n1)+1;
 
return n2;
} 
最終更新:2015年06月01日 15:06