Step 5: Moving the Trooper

Goal:


Let’s add movement to our Storm Trooper.

If I move the right arrow key, then I am moving in the positive X direction

If I move the left arrow key, then I am moving in the negative X direction

Steps:

  1. Still on the “Trooper” sprite, in Events, add a forever loop, then put 2 if statements inside it
  2. From Sensing, place a key space pressed and change it to left arrow inside the first if statement
  3. From Motion, place a change x by -10 inside the first if statement
  4. From Sensing, place a key space pressed and change it to right arrow inside the second if statement
  5. From Motion, place a change x by 10 inside the second if statement

Code:


Click to replay