Page Components JavaScript DHTML




The Count Game














The Count Game

// 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('  ');
}
function count_play()
{
 counter++;
 document.count_form.count_container.value=counter;
 if(counter {
  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();





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!




© 2002 Premshree Pillai.