<br><div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode45'));"><u>复制代码</u></span></div>代码如下:</div> <div class="msgborder" id="phpcode45"> <br> <br> <br> <br> <br> <br><canvas id="tankMap" width="500px" height="300px" style="border:1px solid #d3d3d3;">您的浏览器不支持canvas标签</canvas> <br><script type="text/javascript"> <br />var canvas1=document.getElementById('tankMap'); <br />var ctx=canvas1.getContext('2d'); <br />var myX=30; <br />var myY=30; <br />function drawBall(){ <br />ctx.shadowBlur=30,ctx.shadowColor="#008C46"; <br />ctx.fillStyle='#008C46'; <br />ctx.fillRect(myX,myY,5,30); <br />ctx.fillRect(myX+17,myY,5,30); <br />ctx.fillRect(myX+6,myY+5,10,20); <br />ctx.beginPath(); <br />ctx.fillStyle='#004020'; <br />ctx.arc(myX+11,myY+15,5,0,Math.PI*1.5); <br />ctx.closePath(); <br />ctx.fill(); <br />ctx.strokStyle="#008C46"; <br />ctx.moveTo(myX+11,myY+15); <br />ctx.lineTo(myX+11,myY-5); <br />ctx.stroke(); <br />} <br />drawBall(); <br />function changeDirect(){ <br />var code=event.keyCode; <br />switch(code){ <br />case 87: <br />myY--; <br />break; <br />case 68: <br />myX++; <br />break; <br />case 83: <br />myY++; <br />break; <br />case 65: <br />myX--; <br />break; <br />} <br />ctx.clearRect(0,0,500,300); <br />//重新绘制 <br />drawBall(); <br />} <br /></script> <br> <br> <br> </div>