Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
In this video, you'll add a timer
that will keep score for your game.
The longer the player's sprite avoids the chaser sprite,
the higher the timer score.
To start, select the chaser sprite
and drag out the timer block from the sensing menu.
In Scratch, timer is a variable.
A variable is a storage container
that holds a value for later use.
The timer variable stores the time
the game has been played.
Click the check box next to the timer variable
to display the value of the timer on the stage.
When your player clicks the flag,
the timer resets and starts running from zero.
Program the chaser sprite to say the score
when it catches the player sprite.
Click looks and drag out a save for two seconds block
and place the timer variable inside it.
To test, click the flag, then the save
for two seconds block.
The chaser sprite says the number stored in the timer,
which is how long the game has been played.
Next, program the chaser to say the time
if touching the player.
Select the control menu and drag an if statement
into the forever loop.
Place the say block into this if statement.
Finally, complete the conditional statement.
If the chaser touches the player,
then it should say the value of the timer.
Click the sensing menu and drag out a touching block.
Change the value to the name of your player sprite.
Test your code and play your game.
You can also invite your neighbor to take a turn
and see if they can get a faster time.
If you want to make your game more challenging,
add more chaser sprites by right-clicking the chaser sprite
and selecting duplicate.
Scratch is more fun when you check out other projects
and share yours.
Share what you made with the Scratch community before
you leave today.
Don't forget to write a description and continue
to explore different ways to customize your game
and make it more challenging in the add-ons.
Now it's your turn.
Tell the player their time using if,
touching, say, and timer blocks.
Then, duplicate the chaser sprite
to make more obstacles for the player to avoid.