html5 滚动小球

<html>
<head>
<meta charset="utf-8"/>
</head>
<body onkeydown="keydown()">
<canvas id="tankmap" width="500px" height="300px" style="background-color:black"></canvas>
</body>
</html>
<script>
var arcx=30;
var arcy=30;
var canvas=document.getElementById("tankmap");
canvas.width=window.screen.width;
canvas.height=window.screen.height;
var cxt= canvas.getContext("2d");
drawball();
function drawball(){
cxt.beginPath();
cxt.fillStyle="#BA9658"
cxt.arc(arcx,arcy,10,0,360,true);
cxt.closePath();
cxt.fill();
} function keydown(){
//alert(event.keyCode);
cxt.clearRect(0,0,window.screen.width,window.screen.height);
arcx++;
arcy++;
drawball();
}
</script>
上一篇:UVA 11947 Cancer or Scorpio 水题


下一篇:爆肝一周,用Python在物联网设备上写了个智能语音助手-阿里云智能对话机器人-《神奇的物联网》