WebSiteMadeEasy.net
|
FontsMadeEasy.com
|
RankChecker.net
Google Search:
Learn Java Script Today
|
Over 5000 Free Fonts
|
Tutorials
|
Javascript Forum
|
Other Javascript Resources
|
Cheat Sheet
JavaScript Basics
Inserting Javascript
Complete Tutorial
Advance DHTML Tutorial
Script archive
Advance Tutorials
Alert Scripts
Animation
Audio
Background Effects
Banner Ads
Browser Window
Buttons
Button Forms
Calculcators
Calendars
Clocks & Dates
Cookies
Cursor Effects
DHMTL Games
DHTML Miscellaneous
Equivalents
Forms
Games
IE4+ Scripts
IE5+ Scripts
Image Effects
Image Miscellaneous
Links & Buttons
Math Related
Messages Miscellaneous
Miscellaneous
Mouse Tricks
Navigation
Page Details
Password Protection
Pulldown Menus
Random Stuff
Scrolling
Status Bar
Text Animation
User Detail
User Info
Window Control
Simon Says
Recall your childhood with a JavaScript version of Simon Says. Click the buttons in the same order as Simon (the computer) does to advance to the next level. Each level gets increasingly difficult. See how far you can go.
Level
Insert into <HEAD>
<SCRIPT LANGUAGE="JavaScript"> <!-- Original: Brian Gosselin (bgaudiodr@aol.com) --> <!-- Web Site: http://www.bgaudiodr.iwarp.com --> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin var image_directory = "http://javascript.internet.com/img/simon-says/"; var ok = false; var pcbusy = false; var userturn = true; var butdown = false; var stage = 1; var cnt = 1; var pcclicks = new Array(); var userclicks = new Array(); var pos; var tst = true; var msg = "Click Go!"; btn1 = new Image(); btn1.src = image_directory + "purple.gif"; btn2 = new Image(); btn2.src = image_directory + "yellow.gif"; function updown(isdn) { if (isdn) { document.f[('pl'+pos)].src = image_directory + 'yellow.gif'; } else { document.f[('pl'+pos)].src= image_directory + 'purple.gif'; } } function dopc() { document.f.st.value = stage; if (cnt <= stage) { pcbusy = true; userturn = false; document.f.s.value = "Simon's Turn"; setTimeout("pos=Math.floor((Math.random()*8)+1); updown(true)",500); setTimeout("updown(false) ; pcclicks[cnt]=pos; cnt++; dopc()",1200); } else { userclicks = new Array(); cnt = 1; document.f.s.value = "Player's Turn"; pcbusy = false; userturn = true; document.f.b.focus(); } } function testclicks() { tst = true; for(i = 1;cnt > i; i++) { if (pcclicks[i] == userclicks[i]) { tst = true && tst; } else { tst = false && tst; } } if(tst) { setTimeout("stage++ ; document.f.st.value=stage ; alert('That is correct! Advancing to the next level....'); document.f.s.value=msg ; document.f.b.focus()",300); } else { setTimeout("stage=1 ; cnt=1 ; pcclicks=new Array() ; document.f.st.value=stage ; alert('Sorry, that is not correct. Start a new game if you would like to play again.') ; document.f.s.value=msg",300); } cnt = 1; } function testclk(downflag, pos) { if (userturn&&(!pcbusy)) { if (downflag) { document.f[('pl'+pos)].src = image_directory + 'yellow.gif'; }else{ document.f[('pl'+pos)].src = image_directory + 'purple.gif'; } if (ok && !downflag) { userclicks[cnt] = pos; cnt++; if (pcclicks.length == userclicks.length) { testclicks(); } } } } // End --> </script>
Insert into <BODY>
<center> <form name="f"> <table cellspacing="20" cols="5" width="600"> <tr height="60"> <td colspan="5" align="center"><img src="purple.gif" name="pl1" onMousedown="testclk(true,1)" onMouseup="testclk(false,1)"></td> </tr> <tr height="60"> <td width="20%"> </td> <td align="center" width="20%"><img src="purple.gif" name="pl2" onMousedown="testclk(true,2)" onMouseup="testclk(false,2)"></td> <td width="20%" align="center"><font size="3">Level<br></font><input type="text" size="2" value="1" name="st" readonly></td> <td align="center" width="20%"><img src="purple.gif" name="pl3" onMousedown="testclk(true,3)" onMouseup="testclk(false,3)"></td> <td width="20%"> </td> </tr> <tr height="60"> <td align="center"><img src="purple.gif" name="pl4" onMousedown="testclk(true,4)" onMouseup="testclk(false,4)"></td> <td align="center" colspan="3"><input type="text" name="s" value="Click 'Go!' to start" readonly></td> <td align="center"><img src="purple.gif" name="pl5" onMousedown="testclk(true,5)" onMouseup="testclk(false,5)"></td> </tr> <tr height="60"> <td> </td> <td align="center"><img src="purple.gif" name="pl6" onMousedown="testclk(true,6)" onMouseup="testclk(false,6)"></td> <td align="center"><input type="button" value=" Go! " name="b" onClick="ok=true ; if(!pcbusy) dopc()"></td> <td align="center"><img src="purple.gif" name="pl7" onMousedown="testclk(true,7)" onMouseup="testclk(false,7)"></td> <td> </td> </tr> <tr height="60"> <td colspan="2" align="left"></td> <td align="center"><img src="purple.gif" name="pl8" onMousedown="testclk(true,8)" onMouseup="testclk(false,8)"></td> <td colspan="2" align="right"></td> </tr> </table> </form> </center>
Other Options