Step 4: Winning the Race

Goal:


Now that our player can run, we need to code it so they can actually win the race

If the player reaches the finish line, then we want to set the variable “Winner” to 1 and then broadcast RaceOver!

First, be sure you are on the same blocks of code from the previous step

Steps:

  1. From Control, place an if then block underneath the other if then block that we made in the previous step
  2. From Sensing, place a touching color block inside the if then block
  3. From Variables, place a set to block inside the if statement
  4. Inside that set to block, make sure “Winner” is selected, and that it is set to 1
  5. From Events place a broadcast block
  6. In the broadcast block, set the message to be “RaceOver!”

Code: