经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » CSS » 查看文章
js+css实现飞机大战游戏
来源:jb51  时间:2022/5/9 9:43:34  对本文有异议

本文实例为大家分享了js+css实现飞机大战游戏的具体代码,供大家参考,具体内容如下

用js和css实现,css中定义样式,js中定义了具体的实现事件,例如碰撞、子弹、飞机等。

main.css文件(可根据需要定义):

  1. *{
  2. ? ? margin: 0;
  3. ? ? padding: 0;
  4. }
  5. #contentdiv{
  6. ? ? position: absolute;
  7. ? ? left: 500px;
  8. }
  9. #startdiv{
  10. ? ? width: 320px;
  11. ? ? height: 568px;
  12. ? ? background-image: url(../image/ks.png);
  13. }
  14. button{
  15. ? ? outline: none;
  16. }
  17. #startdiv button{
  18. ? ? position: absolute;
  19. ? ? top: 500px;
  20. ? ? left: 82px;
  21. ? ? width: 150px;
  22. ? ? height: 30px;
  23. ? ? border: 1px solid black;
  24. ? ? border-radius: 30px;
  25. ? ? background-color: #c4c9ca;
  26. }
  27. #maindiv{
  28. ? ? width: 320px;
  29. ? ? height: 568px;
  30. ? ? background-image:url(../image/background_1.png) ;
  31. ? ? display: none;
  32. }
  33. #maindiv img{
  34. ? ? position: absolute;
  35. ? ? z-index: 1;
  36. }
  37. #scorediv{
  38. ? ? font-size: 16px;
  39. ? ? font-weight: bold;
  40. ? ? position: absolute;
  41. ? ? top: 10px;
  42. ? ? left: 10px;
  43. ? ? display: none;
  44. }
  45. #scorediv{
  46. ? ? font-size: 18px;
  47. ? ? font-weight: bold;
  48. }
  49. #suspenddiv{
  50. ? ? position: absolute;
  51. ? ? top: 210px;
  52. ? ? left: 82px;
  53. ? ? display: none;
  54. ? ? z-index: 2;
  55. }
  56. #suspenddiv button{
  57. ? ? width: 150px;
  58. ? ? height: 30px;
  59. ? ? margin-bottom: 20px;
  60. ? ? border: 1px solid black;
  61. ? ? border-radius: 30px;
  62. ? ? background-color: #c4c9ca;
  63. }
  64. #enddiv{
  65. ? ? position: absolute;
  66. ? ? top: 210px;
  67. ? ? left: 75px;
  68. ? ? border: 1px solid gray;
  69. ? ? border-radius: 5px;
  70. ? ? text-align: center;
  71. ? ? background-color:#d7ddde;
  72. ? ? display: none;
  73. ? ? z-index: 2;
  74. }
  75. .plantext{
  76. ? ? width: 160px;
  77. ? ? height: 30px;
  78. ? ? line-height: 30px;
  79. ? ? font-size: 16px;
  80. ? ? font-weight: bold;
  81. }
  82. #planscore{
  83. ? ? width: 160px;
  84. ? ? height: 80px;
  85. ? ? line-height: 80px;
  86. ? ? border-top: 1px solid gray;
  87. ? ? border-bottom: 1px solid gray;
  88. ? ? font-size: 16px;
  89. ? ? font-weight: bold;
  90. }
  91. #enddiv div{
  92. ? ? width: 160px;
  93. ? ? height: 50px;
  94. }
  95. #enddiv div button{
  96. ? ? margin-top:10px ;
  97. ? ? width: 90px;
  98. ? ? height: 30px;
  99. ? ? border: 1px solid gray;
  100. ? ? border-radius: 30px;
  101. }

main.js:

  1. //获得主界面
  2. var mainDiv=document.getElementById("maindiv");
  3. //获得开始界面
  4. var startdiv=document.getElementById("startdiv");
  5. //获得游戏中分数显示界面
  6. var scorediv=document.getElementById("scorediv");
  7. //获得分数界面
  8. var scorelabel=document.getElementById("label");
  9. //获得暂停界面
  10. var suspenddiv=document.getElementById("suspenddiv");
  11. //获得游戏结束界面
  12. var enddiv=document.getElementById("enddiv");
  13. //获得游戏结束后分数统计界面
  14. var planscore=document.getElementById("planscore");
  15. //初始化分数
  16. var scores=0;
  17.  
  18. /*
  19. ?创建飞机类
  20. ?*/
  21. function plan(hp,X,Y,sizeX,sizeY,score,dietime,sudu,boomimage,imagesrc){
  22. ? ? this.planX=X;
  23. ? ? this.planY=Y;
  24. ? ? this.imagenode=null;
  25. ? ? this.planhp=hp;
  26. ? ? this.planscore=score;
  27. ? ? this.plansizeX=sizeX;
  28. ? ? this.plansizeY=sizeY;
  29. ? ? this.planboomimage=boomimage;
  30. ? ? this.planisdie=false;
  31. ? ? this.plandietimes=0;
  32. ? ? this.plandietime=dietime;
  33. ? ? this.plansudu=sudu;
  34. //行为
  35. /*
  36. 移动行为
  37. ? ? ?*/
  38. ? ? this.planmove=function(){
  39. ? ? ? ? if(scores<=50000){
  40. ? ? ? ? ? ? this.imagenode.style.top=this.imagenode.offsetTop+this.plansudu+"px";
  41. ? ? ? ? }
  42. ? ? ? ? else if(scores>50000&&scores<=100000){
  43. ? ? ? ? ? ? this.imagenode.style.top=this.imagenode.offsetTop+this.plansudu+1+"px";
  44. ? ? ? ? }
  45. ? ? ? ? else if(scores>100000&&scores<=150000){
  46. ? ? ? ? ? ? this.imagenode.style.top=this.imagenode.offsetTop+this.plansudu+2+"px";
  47. ? ? ? ? }
  48. ? ? ? ? else if(scores>150000&&scores<=200000){
  49. ? ? ? ? ? ? this.imagenode.style.top=this.imagenode.offsetTop+this.plansudu+3+"px";
  50. ? ? ? ? }
  51. ? ? ? ? else if(scores>200000&&scores<=300000){
  52. ? ? ? ? ? ? this.imagenode.style.top=this.imagenode.offsetTop+this.plansudu+4+"px";
  53. ? ? ? ? }
  54. ? ? ? ? else{
  55. ? ? ? ? ? ? this.imagenode.style.top=this.imagenode.offsetTop+this.plansudu+5+"px";
  56. ? ? ? ? }
  57. ? ? }
  58. ? ? this.init=function(){
  59. ? ? ? ? this.imagenode=document.createElement("img");
  60. ? ? ? ? this.imagenode.style.left=this.planX+"px";
  61. ? ? ? ? this.imagenode.style.top=this.planY+"px";
  62. ? ? ? ? this.imagenode.src=imagesrc;
  63. ? ? ? ? mainDiv.appendChild(this.imagenode);
  64. ? ? }
  65. ? ? this.init();
  66. }
  67.  
  68. /*
  69. 创建子弹类
  70. ?*/
  71. function bullet(X,Y,sizeX,sizeY,imagesrc){
  72. ? ? this.bulletX=X;
  73. ? ? this.bulletY=Y;
  74. ? ? this.bulletimage=null;
  75. ? ? this.bulletattach=1;
  76. ? ? this.bulletsizeX=sizeX;
  77. ? ? this.bulletsizeY=sizeY;
  78. //行为
  79. /*
  80. ?移动行为
  81. ?*/
  82. ? ? this.bulletmove=function(){
  83. ? ? ? ? this.bulletimage.style.top=this.bulletimage.offsetTop-20+"px";
  84. ? ? }
  85. ? ? this.init=function(){
  86. ? ? ? ? this.bulletimage=document.createElement("img");
  87. ? ? ? ? this.bulletimage.style.left= this.bulletX+"px";
  88. ? ? ? ? this.bulletimage.style.top= this.bulletY+"px";
  89. ? ? ? ? this.bulletimage.src=imagesrc;
  90. ? ? ? ? mainDiv.appendChild(this.bulletimage);
  91. ? ? }
  92. ? ? this.init();
  93. }
  94.  
  95. /*
  96. ?创建单行子弹类
  97. ?*/
  98. function oddbullet(X,Y){
  99. ? ? bullet.call(this,X,Y,6,14,"image/bullet1.png");
  100. }
  101.  
  102. /*
  103. 创建敌机类
  104. ?*/
  105. function enemy(hp,a,b,sizeX,sizeY,score,dietime,sudu,boomimage,imagesrc){
  106. ? ? plan.call(this,hp,random(a,b),-100,sizeX,sizeY,score,dietime,sudu,boomimage,imagesrc);
  107. }
  108. //产生min到max之间的随机数
  109. function random(min,max){
  110. ? ? return Math.floor(min+Math.random()*(max-min));
  111. }
  112.  
  113. /*
  114. 创建本方飞机类
  115. ?*/
  116. function ourplan(X,Y){
  117. ? ? var imagesrc="image/my.gif";
  118. ? ? plan.call(this,1,X,Y,66,80,0,660,0,"image/bz.gif",imagesrc);
  119. ? ? this.imagenode.setAttribute('id','ourplan');
  120. }
  121.  
  122. /*
  123. ?创建本方飞机
  124. ?*/
  125. var selfplan=new ourplan(120,485);
  126. //移动事件
  127. var ourPlan=document.getElementById('ourplan');
  128. var yidong=function(){
  129. ? ? var oevent=window.event||arguments[0];
  130. ? ? var chufa=oevent.srcElement||oevent.target;
  131. ? ? var selfplanX=oevent.clientX-500;
  132. ? ? var selfplanY=oevent.clientY;
  133. ? ? ourPlan.style.left=selfplanX-selfplan.plansizeX/2+"px";
  134. ? ? ourPlan.style.top=selfplanY-selfplan.plansizeY/2+"px";
  135. // ? ?document.getElementsByTagName('img')[0].style.left=selfplanX-selfplan.plansizeX/2+"px";
  136. // ? ?document.getElementsByTagName('img')[0]..style.top=selfplanY-selfplan.plansizeY/2+"px";
  137. }
  138. /*
  139. 暂停事件
  140. ?*/
  141. var number=0;
  142. var zanting=function(){
  143. ? ? if(number==0){
  144. ? ? ? ? suspenddiv.style.display="block";
  145. ? ? ? ? if(document.removeEventListener){
  146. ? ? ? ? ? ? mainDiv.removeEventListener("mousemove",yidong,true);
  147. ? ? ? ? ? ? bodyobj.removeEventListener("mousemove",bianjie,true);
  148. ? ? ? ? }
  149. ? ? ? ? else if(document.detachEvent){
  150. ? ? ? ? ? ? mainDiv.detachEvent("onmousemove",yidong);
  151. ? ? ? ? ? ? bodyobj.detachEvent("onmousemove",bianjie);
  152. ? ? ? ? }
  153. ? ? ? ? clearInterval(set);
  154. ? ? ? ? number=1;
  155. ? ? }
  156. ? ? else{
  157. ? ? ? ? suspenddiv.style.display="none";
  158. ? ? ? ? if(document.addEventListener){
  159. ? ? ? ? ? ? mainDiv.addEventListener("mousemove",yidong,true);
  160. ? ? ? ? ? ? bodyobj.addEventListener("mousemove",bianjie,true);
  161. ? ? ? ? }
  162. ? ? ? ? else if(document.attachEvent){
  163. ? ? ? ? ? ? mainDiv.attachEvent("onmousemove",yidong);
  164. ? ? ? ? ? ? bodyobj.attachEvent("onmousemove",bianjie);
  165. ? ? ? ? }
  166. ? ? ? ? set=setInterval(start,20);
  167. ? ? ? ? number=0;
  168. ? ? }
  169. }
  170. //判断本方飞机是否移出边界,如果移出边界,则取消mousemove事件,反之加上mousemove事件
  171. var bianjie=function(){
  172. ? ? var oevent=window.event||arguments[0];
  173. ? ? var bodyobjX=oevent.clientX;
  174. ? ? var bodyobjY=oevent.clientY;
  175. ? ? if(bodyobjX<505||bodyobjX>815||bodyobjY<0||bodyobjY>568){
  176. ? ? ? ? if(document.removeEventListener){
  177. ? ? ? ? ? ? mainDiv.removeEventListener("mousemove",yidong,true);
  178. ? ? ? ? }
  179. ? ? ? ? else if(document.detachEvent){
  180. ? ? ? ? ? ? mainDiv.detachEvent("onmousemove",yidong);
  181. ? ? ? ? }
  182. ? ? }
  183. ? ? else{
  184. ? ? ? ? if(document.addEventListener){
  185. ? ? ? ? ? ? mainDiv.addEventListener("mousemove",yidong,true);
  186. ? ? ? ? }
  187. ? ? ? ? else if(document.attachEvent){
  188. ? ? ? ? ? ? mainDiv.attachEvent("nomousemove",yidong);
  189. ? ? ? ? }
  190. ? ? }
  191. }
  192. //暂停界面重新开始事件
  193. //function chongxinkaishi(){
  194. // ? ?location.reload(true);
  195. // ? ?startdiv.style.display="none";
  196. // ? ?maindiv.style.display="block";
  197. //}
  198. var bodyobj=document.getElementsByTagName("body")[0];
  199. if(document.addEventListener){
  200. ? ? //为本方飞机添加移动和暂停
  201. ? ? mainDiv.addEventListener("mousemove",yidong,true);
  202. ? ? //为本方飞机添加暂停事件
  203. ? ? selfplan.imagenode.addEventListener("click",zanting,true);
  204. ? ? //为body添加判断本方飞机移出边界事件
  205. ? ? bodyobj.addEventListener("mousemove",bianjie,true);
  206. ? ? //为暂停界面的继续按钮添加暂停事件
  207. ? ? suspenddiv.getElementsByTagName("button")[0].addEventListener("click",zanting,true);
  208. // ? ?suspenddiv.getElementsByTagName("button")[1].addEventListener("click",chongxinkaishi,true);
  209. ? ? //为暂停界面的返回主页按钮添加事件
  210. ? ? suspenddiv.getElementsByTagName("button")[2].addEventListener("click",jixu,true);
  211. }
  212. else if(document.attachEvent){
  213. ? ? //为本方飞机添加移动
  214. ? ? mainDiv.attachEvent("onmousemove",yidong);
  215. ? ? //为本方飞机添加暂停事件
  216. ? ? selfplan.imagenode.attachEvent("onclick",zanting);
  217. ? ? //为body添加判断本方飞机移出边界事件
  218. ? ? bodyobj.attachEvent("onmousemove",bianjie);
  219. ? ? //为暂停界面的继续按钮添加暂停事件
  220. ? ? suspenddiv.getElementsByTagName("button")[0].attachEvent("onclick",zanting);
  221. // ? ?suspenddiv.getElementsByTagName("button")[1].attachEvent("click",chongxinkaishi,true);
  222. ? ? //为暂停界面的返回主页按钮添加事件
  223. ? ? suspenddiv.getElementsByTagName("button")[2].attachEvent("click",jixu,true);
  224. }
  225. //初始化隐藏本方飞机
  226. selfplan.imagenode.style.display="none";
  227.  
  228. /*
  229. 敌机对象数组
  230. ?*/
  231. var enemys=[];
  232.  
  233. /*
  234. 子弹对象数组
  235. ?*/
  236. var bullets=[];
  237. var mark=0;
  238. var mark1=0;
  239. var backgroundPositionY=0;
  240. /*
  241. 开始函数
  242. ?*/
  243. function start(){
  244. ? ? mainDiv.style.backgroundPositionY=backgroundPositionY+"px";
  245. ? ? backgroundPositionY+=0.5;
  246. ? ? if(backgroundPositionY==568){
  247. ? ? ? ? backgroundPositionY=0;
  248. ? ? }
  249. ? ? mark++;
  250. ? ? /*
  251. ? ? 创建敌方飞机
  252. ? ? ?*/
  253.  
  254. ? ? if(mark==20){
  255. ? ? ? ? mark1++;
  256. ? ? ? ? //中飞机
  257. ? ? ? ? if(mark1%5==0){
  258. ? ? ? ? ? ? enemys.push(new enemy(6,25,274,46,60,5000,360,random(1,3),"image/zz.gif","image/enemy3_fly_1.png"));
  259. ? ? ? ? }
  260. ? ? ? ? //大飞机
  261. ? ? ? ? if(mark1==20){
  262. ? ? ? ? ? ? enemys.push(new enemy(12,57,210,110,164,30000,540,1,"image/dd.gif","image/enemy2_fly_1.png"));
  263. ? ? ? ? ? ? mark1=0;
  264. ? ? ? ? }
  265. ? ? ? ? //小飞机
  266. ? ? ? ? else{
  267. ? ? ? ? ? ? enemys.push(new enemy(1,19,286,34,24,1000,360,random(1,4),"image/xx.gif","image/enemy1_fly_1.png"));
  268. ? ? ? ? }
  269. ? ? ? ? mark=0;
  270. ? ? }
  271.  
  272. /*
  273. 移动敌方飞机
  274. ?*/
  275. ? ? var enemyslen=enemys.length;
  276. ? ? for(var i=0;i<enemyslen;i++){
  277. ? ? ? ? if(enemys[i].planisdie!=true){
  278. ? ? ? ? ? ? enemys[i].planmove();
  279. ? ? ? ? }
  280. /*
  281. ?如果敌机超出边界,删除敌机
  282. ?*/
  283. ? ? ? ? if(enemys[i].imagenode.offsetTop>568){
  284. ? ? ? ? ? ? mainDiv.removeChild(enemys[i].imagenode);
  285. ? ? ? ? ? ? enemys.splice(i,1);
  286. ? ? ? ? ? ? enemyslen--;
  287. ? ? ? ? }
  288. ? ? ? ? //当敌机死亡标记为true时,经过一段时间后清除敌机
  289. ? ? ? ? if(enemys[i].planisdie==true){
  290. ? ? ? ? ? ? enemys[i].plandietimes+=20;
  291. ? ? ? ? ? ? if(enemys[i].plandietimes==enemys[i].plandietime){
  292. ? ? ? ? ? ? ? ? mainDiv.removeChild(enemys[i].imagenode);
  293. ? ? ? ? ? ? ? ? enemys.splice(i,1);
  294. ? ? ? ? ? ? ? ? enemyslen--;
  295. ? ? ? ? ? ? }
  296. ? ? ? ? }
  297. ? ? }
  298.  
  299. /*
  300. 创建子弹
  301. */
  302. ? ? if(mark%5==0){
  303. ? ? ?bullets.push(new oddbullet(parseInt(selfplan.imagenode.style.left)+1,parseInt(selfplan.imagenode.style.top)-10));
  304. ? ? ?bullets.push(new oddbullet(parseInt(selfplan.imagenode.style.left)+11,parseInt(selfplan.imagenode.style.top)-10));
  305. ? ? ?bullets.push(new oddbullet(parseInt(selfplan.imagenode.style.left)+21,parseInt(selfplan.imagenode.style.top)-10));
  306. ? ? ?bullets.push(new oddbullet(parseInt(selfplan.imagenode.style.left)+31,parseInt(selfplan.imagenode.style.top)-10));
  307. ? ? ?bullets.push(new oddbullet(parseInt(selfplan.imagenode.style.left)+41,parseInt(selfplan.imagenode.style.top)-10));
  308. ? ? ?bullets.push(new oddbullet(parseInt(selfplan.imagenode.style.left)+51,parseInt(selfplan.imagenode.style.top)-10));
  309. ? ? ?bullets.push(new oddbullet(parseInt(selfplan.imagenode.style.left)+61,parseInt(selfplan.imagenode.style.top)-10));
  310. ? ? }
  311.  
  312.  
  313. /*
  314. 移动子弹
  315. */
  316. ? ? var bulletslen=bullets.length;
  317. ? ? for(var i=0;i<bulletslen;i++){
  318. ? ? ? ? bullets[i].bulletmove();
  319. /*
  320. 如果子弹超出边界,删除子弹
  321. */
  322. ? ? ? ? if(bullets[i].bulletimage.offsetTop<0){
  323. ? ? ? ? ? ? mainDiv.removeChild(bullets[i].bulletimage);
  324. ? ? ? ? ? ? bullets.splice(i,1);
  325. ? ? ? ? ? ? bulletslen--;
  326. ? ? ? ? }
  327. ? ? }
  328.  
  329. /*
  330. 碰撞判断
  331. */
  332. ? ? for(var k=0;k<bulletslen;k++){
  333. ? ? ? ? for(var j=0;j<enemyslen;j++){
  334. ? ? ? ? ? ? //判断碰撞本方飞机
  335. ? ? ? ? ? ? if(enemys[j].planisdie==false){
  336. ? ? ? ? ? ? ? ? if(enemys[j].imagenode.offsetLeft+enemys[j].plansizeX>=selfplan.imagenode.offsetLeft&&enemys[j].imagenode.offsetLeft<=selfplan.imagenode.offsetLeft+selfplan.plansizeX){
  337. ? ? ? ? ? ? ? ? ? if(enemys[j].imagenode.offsetTop+enemys[j].plansizeY>=selfplan.imagenode.offsetTop+40&&enemys[j].imagenode.offsetTop<=selfplan.imagenode.offsetTop-20+selfplan.plansizeY){
  338. ? ? ? ? ? ? ? ? ? ? ? //碰撞本方飞机,游戏结束,统计分数
  339. ? ? ? ? ? ? ? ? ? ? ? selfplan.imagenode.src="image/bz.gif";
  340. ? ? ? ? ? ? ? ? ? ? ? enddiv.style.display="block";
  341. ? ? ? ? ? ? ? ? ? ? ? planscore.innerHTML=scores;
  342. ? ? ? ? ? ? ? ? ? ? ? if(document.removeEventListener){
  343. ? ? ? ? ? ? ? ? ? ? ? ? ? mainDiv.removeEventListener("mousemove",yidong,true);
  344. ? ? ? ? ? ? ? ? ? ? ? ? ? bodyobj.removeEventListener("mousemove",bianjie,true);
  345. ? ? ? ? ? ? ? ? ? ? ? }
  346. ? ? ? ? ? ? ? ? ? ? ? else if(document.detachEvent){
  347. ? ? ? ? ? ? ? ? ? ? ? ? ? mainDiv.detachEvent("onmousemove",yidong);
  348. ? ? ? ? ? ? ? ? ? ? ? ? ? bodyobj.removeEventListener("mousemove",bianjie,true);
  349. ? ? ? ? ? ? ? ? ? ? ? }
  350. ? ? ? ? ? ? ? ? ? ? ? clearInterval(set);
  351. ? ? ? ? ? ? ? ? ? }
  352. ? ? ? ? ? ? ? ? }
  353. ? ? ? ? ? ? ? ? //判断子弹与敌机碰撞
  354. ? ? ? ? ? ? ? ? if((bullets[k].bulletimage.offsetLeft+bullets[k].bulletsizeX>enemys[j].imagenode.offsetLeft)&&(bullets[k].bulletimage.offsetLeft<enemys[j].imagenode.offsetLeft+enemys[j].plansizeX)){
  355. ? ? ? ? ? ? ? ? ? ? if(bullets[k].bulletimage.offsetTop<=enemys[j].imagenode.offsetTop+enemys[j].plansizeY&&bullets[k].bulletimage.offsetTop+bullets[k].bulletsizeY>=enemys[j].imagenode.offsetTop){
  356. ? ? ? ? ? ? ? ? ? ? ? ? //敌机血量减子弹攻击力
  357. ? ? ? ? ? ? ? ? ? ? ? ? enemys[j].planhp=enemys[j].planhp-bullets[k].bulletattach;
  358. ? ? ? ? ? ? ? ? ? ? ? ? //敌机血量为0,敌机图片换为爆炸图片,死亡标记为true,计分
  359. ? ? ? ? ? ? ? ? ? ? ? ? if(enemys[j].planhp==0){
  360. ? ? ? ? ? ? ? ? ? ? ? ? ? ? scores=scores+enemys[j].planscore;
  361. ? ? ? ? ? ? ? ? ? ? ? ? ? ? scorelabel.innerHTML=scores;
  362. ? ? ? ? ? ? ? ? ? ? ? ? ? ? enemys[j].imagenode.src=enemys[j].planboomimage;
  363. ? ? ? ? ? ? ? ? ? ? ? ? ? ? enemys[j].planisdie=true;
  364. ? ? ? ? ? ? ? ? ? ? ? ? }
  365. ? ? ? ? ? ? ? ? ? ? ? ? //删除子弹
  366. ? ? ? ? ? ? ? ? ? ? ? ? mainDiv.removeChild(bullets[k].bulletimage);
  367. ? ? ? ? ? ? ? ? ? ? ? ? ? ? bullets.splice(k,1);
  368. ? ? ? ? ? ? ? ? ? ? ? ? ? ? bulletslen--;
  369. ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
  370. ? ? ? ? ? ? ? ? ? ? }
  371. ? ? ? ? ? ? ? ? }
  372. ? ? ? ? ? ? }
  373. ? ? ? ? }
  374. ? ? }
  375. }
  376. /*
  377. 开始游戏按钮点击事件
  378. ?*/
  379. var set;
  380. function begin(){
  381.  
  382. ? ? startdiv.style.display="none";
  383. ? ? mainDiv.style.display="block";
  384. ? ? selfplan.imagenode.style.display="block";
  385. ? ? scorediv.style.display="block";
  386. ? ? /*
  387. ? ? ?调用开始函数
  388. ? ? ?*/
  389. ? ? set=setInterval(start,20);
  390. }
  391. //游戏结束后点击继续按钮事件
  392. function jixu(){
  393. ? ? location.reload(true);
  394. }
  395.  
  396. /*
  397. ? ? 完成界面的初始化
  398. ? ? 敌方小飞机一个
  399. ? ? 我方飞机一个
  400. ?*/

实现界面:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持w3xue。

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号