Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Vocabulary
MWForum
Site Map
Search
Our Team
How do I set up a timer in a game?
Use resett and timer.

Resett stands for reset timer. It resets the built-in timer to 0.

Timer reports elapsed time in tenths of seconds. So to announce the time in seconds, we divide timer by 10.

code
Right-click HERE to Download
Click go to set the balls in motion. How fast can you click all 20 turtles to make them vanish? The instruction for each turtle is touch.

Notes:  

Int outputs the integer portion of the elapsed time (to avoid rapidly-changing decimals when we divide). You may display the time in a textbox or just keep track "behind the scenes" and make an announcement about the time when the game ends. Or you may do both, as in the game above. If you display the time in a textbox, you may round to the nearest second (as demonstrated above), or omit the primitive int if you wish to display tenths of seconds.

If the game runs for quite a long time, as in the 100-ball project below, you might wish to display minutes instead of seconds and display your running score as well. In this project, the final announcement displays elapsed minutes and seconds. Name your textboxes score and minutes and modify your procedures:

code
Right-click HERE to Download
We only see 20 balls at a time, but we must click 100 of them to complete the game. They don't begin disappearing until we have clicked more than 80. (In this way, the game exceeds one minute.)

Note:  These projects also demonstrate two methods for keeping score. See How do I keep score in a game? for more information.

« Previous
Menu
Next »


© copyright 2001 - 2012  OpenWorld Learning.   All rights reserved.