代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
JS
】
射击游戏
作者:
沅青
/ 发布于
2014/11/7
/
1518
脚本说明: 第一步:把如下代码加入<body>区域中 <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var timerID = null; var patno = 1; var cr = "\r\n"; var spcf1 = ""; var spcf2 = ""; var spcf3 = ""; var hitflag = 0; var score = 0; var selec = 0; var rsmiss = ""; function array1(arn) { this.length = arn; for (var ar1 = 0; ar1 <= arn; ar1++) { this[ar1] = 1; } return this; } function init() { blankx = new array1(63); for (var makeblank = 0; makeblank < 63; makeblank++) { blankx[makeblank] = ""; for (var addBlank = 0; addBlank < makeblank; addBlank++) { blankx[makeblank] = blankx[makeblank] + " "; } } faker = new array1(24); face = new array1(2); face[1] = " (O_O) "; face[2] = " (o_o) "; mestotal = new array1(4); interval1(); } function restarter() { inplay = 0; blankno = 0; totalblank = ""; lr = 1; lowerlf = ""; downlf = ""; downno = 0; missilex = 99; missiley = 99; mychrx = 1; myblank = ""; mymove = 0; selec = 1; starter(); } function starter() { document.fmark.win.value=cr+cr+cr+cr+cr+cr+cr+cr+cr+cr +" 请控制好左右键"+cr+cr+cr +" 点射击开始游戏"; selec = 1; } function goleft() { mymove = 0; mychrx = mychrx - 1; if (mychrx <= 0) { mychrx = 1; } } function goright() { mymove = 0 mychrx = mychrx + 1; if (mychrx >= 56) { mychrx = 55; } } function golmax() { if (inplay == 1) { mymove = -1; } } function gormax() { if (inplay == 1){ mymove = 1; } } function fire() { if (inplay == 0){ if (selec == 1){ selec = 9; inplay = 1; init(); } } else { if (missiley == 99){ missiley = 18; missilex = mychrx + 3; } } } function gameover() { score = 0; for (var enerme = 1; enerme < 25; enerme++) { if (faker[enerme] == 1){ score = score + 1; } } if (score == 0) { document.fmark.win.value = cr+cr+cr+cr+cr+cr+cr+cr +" Congratulations!"+cr+cr +" YOU STOPPED THE ENEMY SQUAD!!"; } else { document.fmark.win.value=cr+cr+cr+cr+cr+cr+cr+cr +" 游戏结束"+cr+cr +" 你射中了"+score+"个耙子"; } inplay = 0; } function interval1() { if (missiley != 99) { missiley = missiley - 1; } if (missiley < 0){ missiley = 99; } mychrx = mychrx + mymove; if (mychrx <= 0){ mychrx = 1; } if (mychrx >= 56){ mychrx = 55; } blankno = blankno + lr; totalblank = blankx[blankno]; if (blankno >= 20) { lr = -1; downno = downno + 1; blankno = 20; } if (blankno <= 0) { lr = 1; downno = downno + 1; blankno = 0; } if (downno >= 12) { gameover(); } downlf = ""; for (var upperspc = 0; upperspc < downno; upperspc++) { if (missiley == upperspc) { downlf = downlf + blankx[missilex]+"|"+cr; } else { downlf = downlf+cr; } } if (inplay == 1) { patno = patno + 1; if (patno >= 3) { patno = 1; } for (var addline = 1; addline < 5; addline++){ mestotal[addline] = totalblank; rsmiss = ""; if (missiley == (downno+addline*2-2)) { if (blankno <= missilex) { hitflag = parseInt((missilex-blankno)/7, 10); if (hitflag < 6) { if ((missilex - blankno - (hitflag * 7)) >= 1) { if ((missilex - blankno - (hitflag * 7)) <= 5) { if (faker[(addline * 6) + hitflag - 5] == 1) { faker[(addline * 6) + hitflag - 5] = 0; missiley = 99; } } } }else { if (missilex > (blankno + 42)) { rsmiss = blankx[missilex - blankno - 42]+"|"; } } } else { mestotal[addline] = blankx[missilex]+"|"; if (missilex < (blankno-1)) { mestotal[addline] = mestotal[addline]+blankx[blankno-1-missilex]; } } } for (var addfaker = 1; addfaker < 7; addfaker++) { if (faker[(addline*6)+addfaker-6] == 1) { mestotal[addline] = mestotal[addline]+face[patno]; } else { mestotal[addline] = mestotal[addline]+" "; } } mestotal[addline] = mestotal[addline]+rsmiss; } spcf1 = cr; spcf2 = cr; spcf3 = cr; if (missiley == (downno+1)) { spcf1 = blankx[missilex]+"|"+cr; } if (missiley == (downno+3)) { spcf2 = blankx[missilex]+"|"+cr; } if (missiley == (downno+5)) { spcf3 = blankx[missilex]+"|"+cr; } lowerlf = ""; for (var lowerspc = 0; lowerspc < (11-downno); lowerspc++) { if (missiley == (downno+7+lowerspc)) { lowerlf = lowerlf+blankx[missilex]+"|"+cr; } else { lowerlf = lowerlf+cr; } } myblank = blankx[mychrx]; document.fmark.win.value = downlf+mestotal[1]+cr+spcf1 +mestotal[2]+cr+spcf2+mestotal[3]+cr+spcf3+mestotal[4] +cr+lowerlf+myblank+""+cr+myblank+"(^_^)"; timerID = setTimeout("interval1()",250); } } // End --> </script> <form method=post name=fmark> <table border=1 cellspacing=0 cellpadding=0> <tr><td align=center> <textarea name=win rows=20 cols=63 wrap=virtual></textarea> <pre><input type=button name=button value="<- " onClick="golmax()"> <input type=button name=button value="射击" onClick="fire()"> <input type=button name=button value=" ->" onClick="gormax()"></pre> <input type=button name=button value="新游戏" onClick="restarter()"> </td> </tr> </table> </form> 第二步:把如下代码加入<body>区域中<body bgcolor="#ffffff" OnLoad="restarter()">
试试其它关键字
同语言下
.
Jquery搜索框获取回车事件
.
H5页面添加倒计时,然后自动跳转
.
通过user-agent判断h5页面是在哪个手机App(QQ、微信
.
nginx 禁止未绑定的域名访问
.
JavaScript 获取按键,并屏蔽系统 Window 事件
.
H5之只允许微信浏览器打开,禁止从外部浏览器访问
.
微信打开网址添加在浏览器中打开提示的办法
.
实现JS复制、粘贴,Chrome/Firefox下可用
.
video视频播放,play()、pause()、duration时长、onen
.
HTML5实现MP3上传前的预览和播放时长的获取
可能有用的
.
Jquery搜索框获取回车事件
.
H5页面添加倒计时,然后自动跳转
.
通过user-agent判断h5页面是在哪个手机App(QQ、微信
.
nginx 禁止未绑定的域名访问
.
JavaScript 获取按键,并屏蔽系统 Window 事件
.
H5之只允许微信浏览器打开,禁止从外部浏览器访问
.
微信打开网址添加在浏览器中打开提示的办法
.
实现JS复制、粘贴,Chrome/Firefox下可用
.
video视频播放,play()、pause()、duration时长、onen
.
HTML5实现MP3上传前的预览和播放时长的获取
沅青
贡献的其它代码
(
8
)
.
下载文件前通过HTTP请求获取文件大小
.
java后端处理Apple Pay流程
.
去除数据表中重复行&oracle 替换数据
.
禁止Html5在手机上屏幕页面缩放
.
curl类封装
.
文件上传样式
.
利用百度纠正错误的词语或者字符
.
射击游戏
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3