Step 5: High Score Reset

Goal:


Now it’s time to write the code that resets the high score whenever Iron Man touches green.

When the player obtains a score higher than the current high score displayed on the game screen, then we want to replace the that current high score with the new score the player obtained.

Steps:

  1. Still on the Iron Man sprite, From Events, place a When green flag clicked block to another empty space.
  2. From Control, add a forever loop, then put an IF statement inside it.
  3. From Sensing, add a touching color block inside the condition of the IF statement. click on the colored bubble and change the color to green.
  4. Go back to Control and add another IF statement inside of the first IF statement.
  5. From Operators, place a greater than block inside the condition of the second IF statement.
  6. From Variables, place a score block to the left side of the greater than block and a highscore block on the right side.
  7. From Variables place a set highscore to block inside of the second IF statement and then place a score block to the right of the set highscore to block.
  8. Finally, Go back to events and add a broadcast reset_game under the second IF statement but still inside of the first IF statement.

Code: