<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta charset="UTF-8">
<title>アニメの練習</title>
<script src="jquery.min.js"></script>
<script type="text/javascript">
info=new Array(101);
z=new Array(101);
x = new Array(101);
y = new Array(101);
for(sx=1;sx<101;sx++){
for(n=1;n<11;n++){
if(sx+10>10*n)y[sx]=n;
}
}
for(sx=1;sx<101;sx++){
x[sx]=sx-10*(y[sx]-1);
}
window.onload = function(){
var canvas = document.getElementById("camp");
var ctx = canvas.getContext("2d");
var timer;
var delay = 500;
var n,sx;
n=0;
for(sx=1;sx<101;sx++){
info[sx]="0";
z[sx]=0;
}
function draw(){
for(sx=1;sx<101;sx++){
ctx.fillStyle = 'rgb(255, 0, 0)';
if(z[sx]>50)ctx.fillRect(50+50*x[sx],50+50*y[sx],50,50);
ctx.fillStyle = 'rgb(0, 255, 0)';
if(z[sx]<50)ctx.fillRect(50+50*x[sx],50+50*y[sx],50,50);
}
}
var loop = function(){
jQuery.ajax({
url : "pro",
type : "get",
success : function(message){
var data=message.split(",");
info=data;
}
});
for(sx=1;sx<101;sx++){
z[sx]=0;
if(info[sx].indexOf("A")>-1)z[sx]=100;
}
draw();
clearTimeout(timer);
timer = setTimeout(loop,delay);
}
loop();
}
</script>
</head>
<body>
<canvas id="camp" width="600" height="600"></canvas>
</body>
</html>
最終更新:2013年05月20日 09:30