FatherShark
05-11-2005, 11:41 AM
Who would like to win a 6-pack of their favourite beer (up to the value of $15).
The first person to submit working code which meets the following specifications can have a quarter of a slab on me.....
Produce a small game (game.html), which uses a counter to count every tenth of a second and the user has to try to guess when 5 seconds has elapsed before pressing the stop button.
The user gets a message saying they have won if they press stop after exactly 5 seconds; otherwise a message saying how many seconds had elapsed – with the message saying “well done – the time was ??? seconds” if they are within 0.5 seconds, otherwise “bad luck – the time was ??? seconds”. (Display the number of seconds instead of ???) .
Text on the page should say:”Ready to play?” before the game starts and then ”Press stop when 5 seconds are up” after the game starts – the game starts when the user clicks OK on an alert box. <Hint> show the counter until you get the program working.
You will need 3 functions. One function called start() should be called in the onLoad event, and it will need to display an alert box telling the user how to begin, then start the game by setting a timer to update the elapsed time on a regular basis, and finally change the words on the screen to “Press stop when 5 seconds are up”. The second function needs to update the elapsed time counter – it can show the elapsed time on the screen while you are testing but shouldn’t show the elapsed time on the screen in your final product. The third function finish() needs to be called when the user presses the stop button. It needs to clear the interval and then tell the user whether they have won, done well (between 4.5 and 5.5 seconds), or not done so well.
The first person to submit working code which meets the following specifications can have a quarter of a slab on me.....
Produce a small game (game.html), which uses a counter to count every tenth of a second and the user has to try to guess when 5 seconds has elapsed before pressing the stop button.
The user gets a message saying they have won if they press stop after exactly 5 seconds; otherwise a message saying how many seconds had elapsed – with the message saying “well done – the time was ??? seconds” if they are within 0.5 seconds, otherwise “bad luck – the time was ??? seconds”. (Display the number of seconds instead of ???) .
Text on the page should say:”Ready to play?” before the game starts and then ”Press stop when 5 seconds are up” after the game starts – the game starts when the user clicks OK on an alert box. <Hint> show the counter until you get the program working.
You will need 3 functions. One function called start() should be called in the onLoad event, and it will need to display an alert box telling the user how to begin, then start the game by setting a timer to update the elapsed time on a regular basis, and finally change the words on the screen to “Press stop when 5 seconds are up”. The second function needs to update the elapsed time counter – it can show the elapsed time on the screen while you are testing but shouldn’t show the elapsed time on the screen in your final product. The third function finish() needs to be called when the user presses the stop button. It needs to clear the interval and then tell the user whether they have won, done well (between 4.5 and 5.5 seconds), or not done so well.