<html>
<head>
<title>slot</title>
<script src="jquery.js"></script>
<script src="sample.js"></script>
<script src="svgpaint.js"></script>
</head>
<body onload="sample()">
<p id="memo"></p>
<input id="bt" type="button" value="stop" />
<input id="bt2" type="button" value="start" />
</body>
</html>
var x;
var p;
var z = new Array();
function sample(){
for (s = 1; s < 101;s++ ){
z[s] = 1;
if(Math.random()>0.5)z[s]=2;
}
p = 1;
x=100;
$("#bt").click(function(){
x=200;
});
$("#bt2").click(function(){
x=100;
});
game();
}
function game(){
var timer;
var delay = 100;
var loop = function () {
if (x < 150) p = p + 1;
if (p > 50) p = 1;
paint();
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function paint(){
var sub=new svgpaint();
var str="<svg width=\"300\" height=\"300\">";
for (s = 1; s < 6; s++) {
p1 = p + s;
if (p1 > 50) p1 = p1 - 50;
if (z[p1] == 1) str = str + sub.rect(50, 50 + 50 * s, 50, 50, "red");
if (z[p1] == 2) str = str + sub.rect(50, 50 + 50 * s, 50, 50, "blue");
}
str=str+"</svg>";
$("#memo").html(str);
}
最終更新:2015年05月10日 11:08