開發步驟:
1. 遊戲需求
2. 遊戲分析
3. 遊戲開發與測試
4 遊戲發布
開發心得:
1.寫一行測試一行,避免出錯,不要等到寫了一大堆才測試。
2.軟體領域中的知識在於積累。
以下是代碼:
<html> <head> <title>打字小遊戲</title> <script> var ShuZu=new Array("A","B","C","D"); //聲明一個數組裝住字母 var ZiMu=''; //聲明一個全域變數 function start() { time=setInterval("move()",300); // } function move() { dia.style.top=parseInt(dia.style.top)+20; // parseint(dia.style.top)>500 { dia.style.top=50; } if(parseInt(dia.style.top)==70) { var XiaBiao=Math.floor(Math.random()*4); ZiMu=ShuZu[XiaBiao]; dia.innerHTML=ZiMu; } dia1.style.top=parseInt(dia1.style.top)+20; if(parseInt(dia1.style.top)>500) { dia1.style.top=50; } if(parseInt(dia1.style.top)==70) { var XiaBiao1=Math.floor(Math.random()*4); ZiMu1=ShuZu[XiaBiao1]; dia1.innerHTML=ZiMu1; } dia2.style.top=parseInt(dia2.style.top)+20; if(parseInt(dia2.style.top)>500) { dia2.style.top=50; } if(parseInt(dia2.style.top)==70) { var XiaBiao2=Math.floor(Math.random()*4); ZiMu2=ShuZu[XiaBiao2]; dia2.innerHTML=ZiMu2; } } function stop() { clearInterval(time); } document.onkeydown=keydown; function keydown(e) { var name=String.fromCharCode(e.which); //alert(name); if(ZiMu==name) { dia.style.top=50; } if(ZiMu1==name) { dia1.style.top=50; } if(ZiMu2==name) { dia2.style.top=50; } } </script> </head> <body> <center> <button onClick="start()">開始</button> <button onClick="stop()">結束</button> <div id="dia" style="position: absolute;width:50px;height:50px;background:red;top:50px; left:0;"></div> <div id="dia1" style="position: absolute;width:50px;height:50px;background:red;top:50px; left: 200;"></div> <div id="dia2" style="position: absolute;width:50px;height:50px;background:red;top:50px; left: 500;"></div> </center> </body> </html>