<!DOCTYPE html>
<html>
<head>
<title>Game</title>
</head>
<body>
<canvas id="canvas" width="320" height="320"></canvas>
<style type="text/css">
#canvas{
border:1px solid black;
}
</style>
<script type="text/javascript">
document.getElementById("canvas");
var ctx = canvas.getContext("2d");
x = 160;
y = 160;
rays = [];
blocks = [];
for(i = 0;i < 20;i++){
rays.push({x:0,y:0,radius:0,qq:0,angle:i,raysa:0});
}
blocks.push({x:199,y:170});
function draw(){
ctx.clearRect(0,0,320,320);
for(i in rays){
rays[i].raysa = 0;
for(j = 0;j < 1000;j++){
rays[i].x = Math.cos(rays[i].angle/180*Math.PI) * rays[i].raysa + x;
rays[i].y = Math.sin(rays[i].angle/180*Math.PI) * rays[i].raysa + y;
for(q in blocks){
if(rays[i].x == blocks[q].x && rays[i].y >= blocks[q].y && rays[i].y <= blocks[q].y + 32){
rays[i].qq = 1;
}else{
rays[i].qq = 0;
}
}
if(rays[i].qq == 0){
rays[i].raysa+=1;
}
}
ctx.beginPath();
ctx.moveTo(x,y);
ctx.lineTo(rays[i].x,rays[i].y);
ctx.stroke();
rays[i].angle+=2;
}
for(i in blocks){
ctx.strokeRect(blocks[i].x,blocks[i].y,32,32);
}
}
setInterval(draw,20);
</script>
</body>
</html>