topical media & game development
game-javascript-casual-reflex-game.htm / htm
<!-- TWO STEPS TO INSTALL BUZZY - THE REFLEX TESTER:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original: Pankaj Singh (pankaj040@lycos.com) -->
<script language="javascript">
// CREDITS:
// Buzzy 1.0
// Copyright (c) 2000 Pankaj Singh. All rights reserved.
// IMPORTANT:
// If you add this script to a script-library or script-archive
// you have to add a link to http://ownly4me.netfirms.com on the webpage
var index;
var objBox;
var box;
var iTimesAnimate;
var blnGameStarted;
var wrongClicks;
var TotalDisplay;
index=10;
blnGameStarted = false;
wrongClicks=0;
TotalDisplay = 0;
function changeColorOn(abc)
{
abc.color="white";
abc.backgroundColor="black"
}
function changeColorOff(abc)
{
abc.color="black";
abc.backgroundColor="white"
}
function animate()
{
document.buzzy.btnStart.disabled = true;
if(index < 102)
{
document.all[index-1].style.backgroundColor="white";
document.all[index].style.backgroundColor="yellowgreen";
setTimeout('animate()',75);
index = index + 1;
}
else
{
setTimeout('document.all[101].style.backgroundColor="white"',75);
initialize();
}
}
function checkClick(objBox1)
{
if(blnGameStarted)
{
objBox = objBox1;
if(objBox.backgroundColor == "yellowgreen")
{
document.buzzy.txtScore.value = eval(document.buzzy.txtScore.value) + 1;
}
else
{
wrongClicks = wrongClicks + 1;
objBox.backgroundColor = "red";
setTimeout('objBox.backgroundColor = "white"',200);
}
}
}
function getRandom()
{
return (Math.round(Math.random()*(97-9)))+9;
}
function highlightBox()
{
if(blnGameStarted)
{
box = getRandom();
document.all[box].style.backgroundColor = "yellowgreen";
TotalDisplay = TotalDisplay + 1;
setTimeout('document.all[box].style.backgroundColor = "white"',700);
setTimeout('highlightBox()',800);
}
}
function startTime()
{
if(eval(document.buzzy.txtTime.value) != 0)
{
document.buzzy.txtTime.value = eval(document.buzzy.txtTime.value) - 1;
setTimeout('startTime()',1000);
}
else
{
alert('Time Up!! You Scored ' + document.buzzy.txtScore.value + " out of " + TotalDisplay + "\n\n No. of drunkard%
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.