Page 247 - Scratch Programming Playground
P. 247

In that case, we need to undo the lift and the walking move-
            ment. the change y by -8 and change x by -1 * steps blocks
            undo the Cat sprite’s movement. Multiplying the walk input by
            -1 gives the opposite number of the input and variable.

                Gentle slope: The Cat sprite is    Steep slope: The Cat sprite is
               li ed eight steps and is no longer   li ed eight steps but is still
               touching the ground. The Cat sprite   touching the ground. The Cat
                   can walk up this slope.        sprite cannot walk up this slope.

















                this code is exactly like the code in the Maze Runner
            game in Chapter 3 that blocks the player from walking
            through walls.







            Save Point

            Click the green flag to test the code so far. Use the a and d
            keys to make the cat walk around. the cat should be able to
            walk up the gentle slope on the right, but the steep slope on
            the left should stop the cat. Click the red stop sign and save
            your program.
               If you’re lost, open platformer3.sb in the resources ZIp file
            and continue reading from this point.













                                                           MakING aN advaNCed pLatforMer     221
   242   243   244   245   246   247   248   249   250   251   252