Step 2: Creating the Timer

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:

  1. From Control place a repeat until block under the previous code
  2. From Operators place a < block inside the repeat until block
  3. From Variables place a round “Time Remaining:” block on the left side of the < block
  4. On the right side of the < block, type in the number 1
  5. From Control place a wait block inside the repeat until block, be sure it says 1 seconds
  6. From Variables place a change by block under the wait block
  7. In that change by block, on the left side set its variable to “Time Remaining:” on the right side type in the number -1
  8. From Events place a broadcast block under the repeat until loop
  9. On the broadcast block, set the message to be “GameOver!”

Code: