In this video,
you'll program the variable to hold the high score.
To start, select a chaser
and select make a variable.
This variable will hold the score
so name it something like High Score or Best Time.
Next, program the computer to change
the variable when a new high score is set.
Do this by adding an if statement.
Your if statement should read:
when the player gets caught,
if the value of the timer is greater than
the value of the high score,
then the high score should be set
to the value of the timer.
To program this, drag another if statement
into the if touching player block.
This should read:
If timer is greater than high score.
So click the operators menu
and select the greater than operator.
Then add a timer variable from sensing
and a high score variable.
Now, set the highest score to equal the timer.
Add a set high score to block.
Then add the timer here.
Now, when the player's score is displayed,
the computer will check
if the timer is greater than the highest score.
If it is, the value in the timer
will become the new highest score.
Now it's your turn.
Make a new variable to hold the high score.
Set the value of the high score using
if, touching, greater than, and high score blocks.
Set the highest score equal to the timer
using set and timer blocks.