<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> 🎜> <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.shadowor="ctx. #008C46"; <br />ctx.fillStyle='#008C46'; <br />ctx.fillRect(myX,myY,5,30); <br />ctx.fillRect(myX 17,myY,5,30); 🎜>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 />break ; <br />case 83: <br />myY ; <br />break; <br />case 65: <br />myX--; <br />break; <br />} <br />ctx.clearRect(0,00,500,300) ; <br />//重新繪製<br />drawBall(); <br />} <br /></script> </div>