Step 7: Moving the Rocks

Goal:


Now that we have set up our variables, let’s call on those variables to make the rocks move in whichever direction was randomly chosen.

However, the rocks will now get stuck on walls just like the fish did! We’ll fix this next.

Steps:

  1. Stay on the “Rocks” sprite.
  2. From Control, place a forever block.
  3. From Motion, place a change x by block.
  4. From Variables, place a round xSpeed block inside the change x by block.
  5. From Motion, place a change y by block.
  6. From Variables, place a round ySpeed block inside the change y by block.

Code: