Page 238 - Scratch Programming Playground
P. 238

and download the ZIp file to your computer by right-clicking
                         the link and selecting Save link as or Save target as. extract
                         all the files from the ZIp file. the skeleton project file has all
                         the sprites already loaded, so you’ll only need to drag the code
                         blocks into each sprite.



                           A     create gravity, falling,
                                and landing


                         In the first part, we’ll
                         add gravity, falling, and
                         landing code, similar to
                         the Basketball game in
                         Chapter 4. the important
                         difference is that in the
                         platform game, the cat lands
                         when it touches a ground
                         sprite rather than the bot-
                         tom of the Stage. Coding
                         is a bit trickier, because
                         we want the ground to
                         have hills and eventually
                         platforms!
                             to start, click the text field at the top left of the Scratch
                         editor and rename the project from Untitled to Platformer.
                         1. Create the Ground Sprite


                         Let’s use a simple shape for the ground in the first few scripts,
                         just to explore how the code will work.
                             Click the Paint new sprite button next to New sprite
                         to create a temporary ground sprite while you learn about
                         platforming code. In the paint editor, use the Brush or Line
                         tool to draw a shape for the ground. You can make the lines
                         thicker by using the Line width slider in the bottom-left corner
                         of the paint editor. Be sure to draw a gentle slope on the right
                         and a steep slope on the left.







      212   Chapter 9
   233   234   235   236   237   238   239   240   241   242   243