Goal:
Now let’s add on to this previous code and add a loop.
This loop will be used to slowly decrease our time until it hits 0, when it does it will send a “GameOver!” message.
Steps:
- From Control place a repeat until block under the previous code.
- From Operators place a < block inside the repeat until block.
- From Variables place a round “Time Remaining:” block on the left side of the < block.
- On the right side of the < block, type in the number 1.
- From Control place a wait block inside the repeat until block, be sure it says 1 seconds.
- From Variables place a change by block and set its variable to “Time Remaining:” and the number value to -1.
- From Events place a broadcast block under the repeat until loop.
- On the broadcast block, set the message to be “GameOver!”.
- From Variables place a set to block under the broadcast block.
- Set the variable to “GameOver:” and the number value to 1.