Step 6: Medium Target Movement/Reset

Goal:


Let’s code the medium target.

The code for the medium target is very similar to the code for the easy target; however, there are some small differences.

These differences include the position and speed. The Medium target will move towards the left first then when it reaches the edge it will move to the right.

See if you can spot them in the code and explain why we changed them!

Steps:

  1. Click on the “Medium Target” sprite
  2. From Events, place a when flag clicked block
  3. From Looks, place a show block
  4. From Motion, place a set y to block and change the number to 60
  5. From Control, place a forever block
  6. From Motion, place a change x by block and change the number to -7
  7. From Control, place an If statement block
  8. From Operators, place a <(less than) block inside the If statement
  9. From Motion, place a round x position block on the left side and change the number on the right side to -230
  10. From Motion, place a set x to block and change the number to 220

Code: