Board logo

标题: 射击代码 [打印本页]

作者: 729796565    时间: 2010-7-30 13:58     标题: 射击代码

<html>
<head>
<title>射击</title>
</head><body>
<!--将以下代码加入HTML的<Body></Body>之间-->
<script language="JavaScript">
function MakeArray( n){
     this.length = n;
     for (var i = 1; i <= n; i++) {
         this = 0
     }
     return this
}
var d0 = new Date();
var r0 = d0.getSeconds();
function poor_rand(){
     d1 = new Date();
     r0 = (r0 * r0 + r0 + d1.getSeconds()) % 3721 ;
     return r0 % width_n;
}
var height_n = 8;
var width_n =5;
var enemy = new MakeArray( width_n);
var wtime;
var score;
var gameover;
document.write( "<FORM NAME='fm1'>");
document.write( "<INPUT TYPE='text' NAME='message' SIZE=20>");
document.write( "</FORM>");
document.write( "<FORM NAME='fm2'><TABLE>");
for( var i=0; i<height_n; i++){
     document.write( "<TR>");
     for( var j=0;j<width_n; j++){
         document.write( "<TD><CENTER><INPUT TYPE='radio'></CENTER></TD>");
     }
     document.write( "</TR>");
}
document.write( "<TR>");
for( var j=0;j<width_n; j++){
     document.write( "<TD><INPUT TYPE='button' VALUE='射' onClick='fire("
         + j + ")'></TD>");
}
document.write( "</TR>");
document.write( "</TABLE>");
document.write( "<INPUT TYPE='button' VALUE='开始' onClick='game_start()'>");
document.write( "</FORM>");
function come(){
     var n = poor_rand();
     document.fm2.elements[ width_n * enemy[n+1] + n].checked = true;
     enemy[n+1]++;
     if( enemy[n+1] < height_n){
         setTimeout("come()", wtime);
     }else{
       gameover = true;
       document.fm1.message.value =  "游戏结束:" + score ;
     }
}
function fire( n){
     if( gameover ) return;
     for( var i=0; i<enemy[n+1]; i++){
         document.fm2.elements[ width_n * i + n].checked = false;
     }
     score += enemy[ n+1];
     document.fm1.message.value = "分数:" + score;
     enemy[ n+1] = 0;
     if( wtime > 50){ wtime -= 10};
}
function game_start(){
    for( var n=0; n<width_n; n++){
         for( var i=0; i<enemy[n+1]; i++){
             document.fm2.elements[ width_n * i + n].checked = false;
         }
         enemy[n+1] = 0;
     }
     wtime = 150;
     score = 0;
     gameover = false;
     document.fm1.message.value = "分数:" + score;
     setTimeout("come()", wtime);
}
</script>
</body></html>
<a href="http://775885.tk">欢迎访问中国建站之家网页特效集</a>
本篇文章来源于 “中国建站之家网页特效集 QQ:729796565” 转载请以链接形式注明出处 网址:http://www.775885.tk/index_k/00006.htm




欢迎光临 免费国外空间,国外免费空间, (http://idc866.com/) Powered by Discuz! 7.2