Step 3: Making the Player Run

Goal:


Now that the player has a runSpeed, our next step is to do something with it

Just like before, we will need to constantly make sure that the race isn’t over yet (repeat until “Winner” > 0)

If the race isn’t over yet, then we change the player’s x by the “runSpeed”

Steps:

  1. Stay on the “Player” sprite
  2. From Events, place a new when I receive block
  3. Set the message to be “StartRace!”
  4. From Control, place a repeat until block
  5. From Operators, place a > block inside the repeat until block
  6. From Variables, place a round “Winner” block on the left side of the > block
  7. Type in 0 on the right side of the > block
  8. From Control, place an if then block
  9. From Operators, place a > block inside the if then block
  10. From Variables place a round “runSpeed” block on the left side of the > block
  11. Type in 0 on the right side of the > block
  12. From Motion place a change x by block
  13. From Variables place “runSpeed” inside the change x by block

Code: