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:
- Still on the Iron Man sprite, From Events, place a When green flag clicked block to another empty space.
- From Control, add a forever loop, then put an IF statement inside it.
- 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.
- Go back to Control and add another IF statement inside of the first IF statement.
- From Operators, place a greater than block inside the condition of the second IF statement.
- From Variables, place a score block to the left side of the greater than block and a highscore block on the right side.
- 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.
- Finally, Go back to events and add a broadcast reset_game under the second IF statement but still inside of the first IF statement.