Count Game : Game « Page Components « JavaScript DHTML






Count Game

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>The Count Game</title>
</head>
<body bgcolor="#FFFFFF">

<table cellspacing="0" cellpadding="1" bgcolor="#73994C" width="400"><tr><td>
<table cellspacing="0" cellpadding="1" bgcolor="#86B259" width="100%"><tr><td>
<table cellspacing="0" cellpadding="1" bgcolor="#99CC66" width="100%"><tr><td>
<table cellspacing="0" cellpadding="1" bgcolor="#ACE573" width="100%"><tr><td>
<table cellspacing="0" cellpadding="1" bgcolor="#BFFF80" width="100%"><tr><td>
<table cellspacing="0" cellpadding="1" bgcolor="#BFFF80" width="100%"><tr><td>
<table cellspacing="0" cellpadding="1" bgcolor="#ACE573" width="100%"><tr><td>
<table cellspacing="0" cellpadding="1" bgcolor="#99CC66" width="100%"><tr><td>
<table cellspacing="0" cellpadding="1" bgcolor="#86B259" width="100%"><tr><td>

<table cellspacing="0" cellpadding="1" bgcolor="#73994C" width="100%"><tr><td>
<table bgcolor="#99CC66" width="100%" height="100"><tr><td>
<table border="2" bordercolor="#BFFF80" width="100%" cellspacing="0"><tr><td align="middle">
<font face="verdana,arial,helvetica" color="#BFFF80" size="6pt"><b>The Count Game</b></font>
<script language="JavaScript">
// The Count Game
// (c) 2002 Premshree Pillai
// http://www.qiksearch.com, http://javascript.qik.cjb.net
// qiksearch@rediffmail.com

var counter=0;
var speed_count=1000;
var maxVal=150;
var playFlag=true;
function count_init()
{
 document.write('<form name="count_form"><input type="button" value="0" name="count_container" style="border:#808080 solid 2px; height:22px; background:#EFEFEF; width:100px; cursor:pointer" onClick="choose_ps();">&nbsp;<input type="text" name="count_op" style="border:#808080 solid 2px; height:22px; width:100px">&nbsp;<input type="button" value="Restart" name="count_restart" style="border:#808080 solid 2px; height:22px; background:#EFEFEF; width:100px; cursor:pointer" onClick="location.reload();"></form>');
}

function count_play()
{
 counter++;
 document.count_form.count_container.value=counter;
 if(counter<maxVal)
 {
  setTimeout("count_play()",speed_count);
 }
 if(((counter%10)==0)||(counter==1))
 {
  speed_count/=10;
 }
}

function choose_ps()
{
 if(playFlag)
 {
  reset_count();
  playFlag=false;
  count_play();
 }
 else
 {
  document.count_form.count_op.value=counter;
  document.count_form.count_container.value=document.count_form.count_op.value;
  speed_count*=100000000000000000000;
  playFlag=true;
  if((document.count_form.count_op.value<=100)&&(document.count_form.count_op.value>=98))
  {
   alert('You Won!');
  }
  else
  {
   alert('Oops! You lost!');
  }
 }
}

function reset_count()
{
 counter=0;
 speed_count=1000;
 document.count_form.count_container.value=counter;
 document.count_form.count_op.value='';
}

count_init();

</script>
</td></tr></table>
<br>
<font face="verdana,arial,helvetica" size="-1">
To play the game, click on the button to the left. The counter will start. Click on the button again to stop the counter. To win, you have to stop the counter between "98-100" (including extremes). The number you clicked on will be displayed on the right. Simple!
<br>
<br>
<table bgcolor="#73994C" width="100%"><tr><td><font face="verdana,arial,helvetica" size="-2" color="#BFFF80">&#169; 2002 Premshree Pillai.</font></td></tr></table>
</td></tr></table>

</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>

</body>
</html>

           
       








Related examples in the same category

1.Chess: Draughts
2.Mine game
3.Word search game
4.Ranisima english
5.Yasminuroban (by Joan Alba Maldonado)
6.Level editor for Yasminuroban by Joan Alba Maldonado
7.js mine sweeper
8.Another tictactoe
9.Marbles
10.Jigsaw
11.Game sudoku
12.Game PunkPong
13.Tetris in Javascript
14.Arrange Game
15.Guess Number
16.Tic tac toe
17. A JavaScript Hangman Game
18.Game library
19.Type Tutor
20.Game: Place It (IE only)
21.HylZee