Tip: You can modify some of the code before running
JS Game code-Rabbit Crab race <script language= "JavaScript" > Function Browser_check () {var browser = document.all;} var pic = "CRA B.gif "; <!--set picture variable--> var mask = ' var fancy, stake, level, winner; <!--set parameter variable--> var total = 10000; <!--set score variable--> var running = 0; <!--set start variable--> var stopped = 1; <!--set stop variable--> var odds = new Array (); var step = new Array (); var band= ' <table border=1 bordercolor= #000000 width=300 height=160 align=center cellpadding=0 CELLSPACING=0>< FORM name= "F" ><TR>; Band + + <td colspan=4 bgcolor= #C0C0C0 align=center valign=middle><input type=text name= "msg" SIZE=24 VALUE= "" & Gt;</td></tr><tr> '; <!--set crab Picture Style--> Band + = ' <TD bgcolor= #FF0000 align=center valign=middle><input type=text name= "box0" size=3 value= "" onfocus= "blur (This)" & Gt;<br><input type=radio name= "Back" value= "Red" onclick= "Choose_fancy" (This.form,this.value); ></TD> '; <!--set crab Picture Style--> band + + <td bgcolor= #00FF00 align=center valign=middle><input type=text name= "Box1" Size=3 value= "" onfocus= "blur (This)" ><br><input Type=radio name= "Back" value= "green" onclick= "choose_fancy ( This.form,this.value); " ></TD> '; <!--set crab Picture Style--> band + + <td bgcolor= #0000FF align=center valign=middle><input type=text name= "Box2" Size=3 value= "" onfocus= "blur (This)" ><br><input Type=radio name= "Back" value= "Blue" onclick= "choose_fancy ( This.form,this.value); " ></TD> '; <!--set crab Picture Style--> band + + <td bgcolor= #FFF000 align=center valign=middle><input type=text name= "Box3" Size=3 value= "" onfocus= "blur (This)" ><br><input type=radio name= ' back ' value= ' yellow ' onclick= "Choose_fancy (this.form,this.value);" ></TD></TR><TR> '; <!--set button style--> band = ' <td bgcolor= #C0C0C0 align=center valign=middle><input type=button value= ' 1000 ' on click= "Choose_stake (this.form,this.value);" ></TD> '; <!--set button style--> band + + <td bgcolor= #C0C0C0 align=center valign=middle><input type=button value= "" click= "Choose_stake (this.form,this.value);" ></TD> '; <!--set button style--> band = ' <td bgcolor= #C0C0C0 align=center valign=middle><input type=button value= ' 3000 ' on click= "Choose_stake (this.form,this.value);" ></TD> '; <!--set button style--> band = ' <td bgcolor= #C0C0C0 align=center valign=middle><input type=button value= ' 4000 ' on click= "Choose_stake (this.form,this.value);" ></TD></TR><TR> '; <!--set button style--> band + + <td bgcolor= #C0C0C0 align=center valign=middle><input type=button name= "Go" VALUE = "Start" onclick= "Lets_go (this.form);" ></TD>'; <!--set button style--> band + + <td bgcolor= #C0C0C0 align=center valign=middle><input name= "WLT" Type=text Value= ' +total+ ' onfocus= ' blur (This) "></TD>"; <!--set button style--> band = ' <td colspan=2 bgcolor= #C0C0C0 align=center valign=middle><input Type=button NAME= "Next" value= "Again" onclick= "Init ();" ></TD></TR></FORM></TABLE> '; if (document.all) {var content= (' <div id= ' Trak ' ></DIV> '); content + = (' <div id= ' line ' ></DIV> ') ; Content + = (' <div id= ' book ' > ' +band+ ' </DIV> '); Content + = (' <div id= "Redc" > ' +mask+ ' </DIV> '); Content + = (' <div id= "GRNC" > ' +mask+ ' </DIV> '); Content + = (' <div id= "Bluc" > ' +mask+ ' </DIV> '); Content + = (' <div id= "YELC" > ' +mask+ ' </DIV> '); } document.write (content); Init (); function init () {if (!running) {fancy= ""; stake= ""; level= ""; stopped = 0; for (i=0; i<4; i++) {Odds[i] = Math.Round (M Ath.random () * 3) +1; Step[i= eval (10-odds[i]); Odds[i] + = "/1"; if (document.all) {document.all.msg.value = "bet which crab will win?" "Document.all.box0.value = Odds[0]; Document.all.box1.value = odds[1]; Document.all.box2.value = odds[2]; Document.all.box3.value = odds[3]; For (i=0 i<4; i++) {document.all.back[i].checked=0;} document.all.redc.style.left=20; document.all.grnc.style.left=20; document.all.bluc.style.left=20; document.all.yelc.style.left=20; }} function Choose_fancy (F,color) {if (!running) {switch (color) {case "red": level=odds[0]; break; case "green": le VEL=ODDS[1]; Break Case "Blue": level=odds[2]; Break Case "Yellow": level=odds[3]; Break } fancy = color; if (Stake!= "") f.msg.value= "wager: +fancy+" "+stake+" ("+level+") "; else f.msg.value= "select" +fancy; }} function Choose_stake (f,amount) {if (!running) {stake = amount; if (Fancy!= "") f.msg.value= "bet: +fancy+" "+stake+" ( "+level+") "; else F.msg.value = "wager" +stake; }} function Lets_go (f) {if (!running && stopped) init (); if (!running &&!stopped) {if (Stake > parseint (f.wlt.value)) f.msg.value= "Your bets are not enough! "; else if (fancy = = "") f.msg.value= "Choose a Color"; else if (stake = = "") f.msg.value= "please bet!" "; else {running = 1; Run_race ();}} function Run_race () {var n = Math.floor (Math.random () * 4); if (document.all) {switch (n) {case 0:document.all.redc.s Tyle.left = parseint (document.all.redc.style.left) +step[0]; if (parseint (document.all.redc.style.left) >=) {Document.all.redc.style.left = winner =--"red"; running = 0; sto pped = 1; } break; Case 1:document.all.grnc.style.left = parseint (document.all.grnc.style.left) +step[1]; if (parseint (document.all.grnc.style.left) >=) {Document.all.grnc.style.left = winner =--"green"; running = 0; sto pped = 1; } break; Case 2:document.all.bluc.style.left = parseint (document.all.bluc.style.left) +step[2]; if (parseint (document.all.bluc.style.left) >=) {Document.all.bluc.style.left = winner =--"blue"; running = 0; sto pped = 1; } break; Case 3:document. All.yelc.style.left = parseint (document.all.yelc.style.left) +step[3]; if (parseint (document.all.yelc.style.left) >=) {Document.all.yelc.style.left = winner =--"yellow"; running = 0; sto pped = 1; } break; } if (running) window.settimeout ("Run_race ()", 100); else results (); function results () {if (document.all) {if (winner = = fancy) {var winnings = parseint (stake) * parseint (Level.charat (0)) ; Document.f.msg.value = winner+ "victory: Get" +winnings; Total + = winnings; Document.f.wlt.value = total; else {document.f.msg.value = winner+ "victory: Lost" +stake Total-= parseint (stake); document.f.wlt.value = total;} if (Parsei NT (document.f.wlt.value) = = 0) var refill = confirm ("You lost!") Do you want to do it again? "); if (refill) {total = 10000, Document.f.wlt.value = total; init ();}} } browser_check () </script>
Tip: You can modify some of the code before running