JS Games-Shooting games

Source: Internet
Author: User
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 ' &GT;&LT;/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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.