Tip: You can modify some of the code before running
JS game-Shooting Games <script language= "JavaScript" > Function Makearray (n) {this.length = n; for (var i = 1; I <= n; i++) {this[i] = 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 ("<center><input type= ' text ' name= ' message ' size=16>"); document.write ("</FORM>"); document.write ("<form name= ' fm2 ' ><TABLE>"); for (var i=0 i<peight_n; i++) {document.write ("<TR>"); For (Var j=0;j<width_n; j + +) {document.write ("<td><center><input type= ' Radio ' ></CENTER&G") T;</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= ' Start ' onclick= ' Game_start () ' >"); document.write ("</FORM></center>"); 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 = "Game Over:" + 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:" + score; enemy[n+1] = 0; if (Wtime >) {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:" + score; SetTimeout ("Come ()", wtime); } </script>
Tip: You can modify some of the code before running