Step 5: Easy Target Movement

Goal:


Our targets will move side to side forever during the game.

In our code, we want the easy target to constantly move to the right until it reaches the edge of the screen. Therefore we need to move it in the positive x direction.

Once it reaches the end of the screen it will move to the left edge of the screen. Now we need to move it in the negative x direction.

Steps:

  1. Stay on the “Easy Target” sprite
  2. From Motion, place a change x by block. Change the number to 5
  3. From Control, place an if statement
  4. From Operators, place a >(greater than) block inside the If block
  5. From Motion, place the set x position block on the left side and change the number on the right side to 230
  6. From Motion, place a set x to and change the number to -210

Code:


Click to replay