Page 269 - Scratch Programming Playground
P. 269

also, if the cat is moving from the left side of the Stage, its
            y position will be less than 5. this will put it inside the ground
            when moved to the right edge of the Stage, so an if then block
            checks for this condition and sets the y position to 5.





                                        When you set the y position to 5,
                                        the cat ends up above the ground.


               The cat wraps
              around the Stage.


                                       If you don’t change the y position,
                                        the cat ends up inside the ground.




                the other if then block wraps the Cat to the left edge of
            the Stage if it’s on the right edge (that is, its x position is
            greater than 230.)





            Save Point

            Click the green flag to test the code so far. Make sure the cat
            can walk off the left edge of the Stage and wrap around to the
            right, and vice versa. then click the red stop sign and save
            your program.
               If you’re lost, open platformer8.sb in the resources ZIp file
            and continue reading from this point.






             H     add crab enemies and
                   apples

            the entire Platformer game setup is complete! the player can
            make the Cat sprite walk, jump, fall, and stand on platforms.




                                                           MakING aN advaNCed pLatforMer 243
   264   265   266   267   268   269   270   271   272   273   274