Step 4: Keeping Track of a High Score

Goal:


There’s one last thing we’re going to need our game manager to keep track of, and that’s the high score.

When the score is greater than the high score, we want to replace the variable high score with the variable score.

Be sure you are still coding on the backdrop/stage as all this code will also go here.

Steps:

  1. From Events place a when I receive block and set the message to be “GameOver!”.
  2. From Control place an if then block.
  3. From Operators place a “>” block inside the if then block.
  4. From Variables place a round “Score:” block on the left side of the “>” block.
  5. From Variables place a round “High Score:” block on the right side of the “>” block.
  6. From Variables place a set to block inside the if then block.
  7. Inside the set to block on the left side, set the variable to be “High Score:”.
  8. From Variables place a round “Score:” block on the right side of the set to block.

Code: