js键盘小游戏(新手)
来源:互联网 发布:手机淘宝首页轮播大图 编辑:程序博客网 时间:2024/05/16 11:11
开发步骤:
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>
- js键盘小游戏(新手)
- js键盘小游戏
- UNITY新手小游戏(二)
- 键盘小游戏
- 键盘小游戏
- 三子棋小游戏(新手必看)
- 利用js写的见缝插针小游戏(推荐给新手)
- UNITY新手小游戏
- 小游戏键盘操作
- js小游戏
- js小游戏
- 关于IOS键盘样式(给新手)
- 键盘控制小游戏简化版(功能添加更新。。)
- js拖拽俄罗斯方块小游戏(一)
- js--贪吃蛇小游戏(加墙)
- JS小游戏:贪吃蛇(附源码)
- JS小游戏 - 盖房子
- js 小游戏地址
- linux read 用法
- readmsg
- iOS 7与Android 4.2功能大PK 到底“新”在哪里?
- H264-1
- Core Animation
- js键盘小游戏(新手)
- Android四种crash
- H264-2
- Linux下网卡bond的几种模式
- db2 命令大全
- Entity Framework底层操作封装(2)
- 手机通讯录备份之后,如何在电脑上打开并且如何方便快速的导入另一个手机中
- 中学德育三大难题:手机、电脑、早恋
- [Android]文本框实现搜索和清空效果