arrow_back High Score!
In this game, the player scores more points the longer they avoid the chasers. In this screencast, you’ll learn how to store a high score in a variable, then you’ll try the programming on your own.
To begin, select a chaser, click on the data menu, and select “make a variable”.
Computer scientists often work together on the same project, so it’s important to use names that would be easy for anyone who looks at the code on your project to understand.
This variable will hold the score, so name it something logical like, “High Score” or “Best Time.”
Now that you’ve created a place to store the high score, you need to program the computer to change it when a new high score is set. You will do this by adding an if statement.
Your if statement should read: When the player gets caught, 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 a “greater than” operator.
Then, add a “timer” variable from sensing and a “high score” variable from data.
Now, you need to set the high 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 high score. If it is, the value in the timer will become the new high score.
Now, it’s your turn! Once you’ve finished programming, set your own high score, then challenge a neighbor to beat it.