Step 5: Creating Variables for the Rocks

Goal:


Now let’s start adding code to the rocks in our game by adding new variables.

These new variables will set the speed of the rocks in the x and y direction.

Steps:

  1. Select the “Rocks” sprite.
  2. From Variables, create 2 new variables call these “xSpeed” and “ySpeed” (Be sure to select “For this sprite only” and be sure you are on the “Rocks” sprite).
  3. Click on the check box to uncheck the variables you just created.

Code:


Click to replay