Scratch Programming Playground: Learn to Program by Making Cool Games
The Complete Program 28 Turbo Mode 28 Version 2 0 Rainbow Triangles 29 Version 3 0 Two Rainbow Lines 30 Version 4 0 You Decide 31 Summary 32 Review Questions 33 3 Maze Runner 35 Sketch Out the Design 36 A Make the Cat Walk Around 38 Explore X and Y-Coordinates 38 1 Add Movement Code to the Player Sprite 40 2 Duplicate the Movement Code for the Cat Sprite 41 B Make the Maze Levels 43 3 Download the Maze Images 43 4 Change the Backdrop 43 5 Start at the First Maze 43 C Keep the Cat from Walking Through Walls 44 6 Check Whether the Cat Is Touching the Walls 44 D Make a Goal at the End of the Maze 46 7 Create the Apple Sprite 47 8 Detect When the Player Reaches the Apple 47 9 Add the Broadcast Handling Code to the Maze Sprite 49 The Complete Program 49 Version 2 0 Two-Player Mode 51 Duplicate the Apple Sprite 51 Modify the Apple2 Sprite’s Code 52 Duplicate the Orange Cat Sprite 52 Modify the Code for the Blue Cat Sprite 53 Go Back to the Starting Position 55 Version 3 0 Traps 56 Draw a new Sprite for the Traps 56 Create a Second Costume for the Traps 57 Add Cloning Code for the Traps 58 Modify the Orange Cat Code 59 Copy the Code from Orange Cat to Blue Cat 61 Cheat Mode Walk Through Walls 62 Add the Walk-Through-Walls Code to Orange Cat 63 Add the Walk-Through-Walls Code to Blue Cat 63 Summary 64 Review Questions 65 x COnTEnTS In DETAIL
4 Shooting Hoops with Gravity 67 Sketch Out the Design 68 A Make the Cat Jump and Fall 69 1 Add the Gravity Code to the Cat Sprite 69 Explore For All Sprites vs For This Sprite Only 71 2 Add the Ground Level Code 73 3 Add the Jumping Code to the Cat Sprite 74 B Make the Cat Move Left and Right 75 4 Add the Walking Code to the Cat Sprite 76 C Make a Hovering Basketball Hoop 77 5 Create the Hoop Sprite 77 6 Create the Hitbox Sprite 79 D Make the Cat Shoot Hoops 81 7 Create the Basketball Sprite 81 8 Add the Code for the Basketball Sprite 82 9 Detect Whether a Basket Is Made 83 10 Fix the Scoring Bug 85 The Complete Program 87 Version 2 0 Two-Player Mode 88 Duplicate the Cat and Basketball Sprites 88 Modify the Code for the Cat2 Sprite 89 Modify the Code for the Basketball2 Sprite 90 Cheat Mode Freeze the Hoop 91 Summary 92 Review Questions 92 5 A Polished Brick Breaker Game 93 Sketch Out the Design 94 A Make a Paddle That Moves Left and Right 95 1 Create the Paddle Sprite 95 Explore Rotation Styles 97 B Make a Ball That Bounces Off the Walls 98 2 Create the Tennis Ball Sprite 98 C Make the Ball Bounce Off the Paddle 99 3 Add the Bounce Code to the Tennis Ball Sprite 99 Explore Cloning 101 D Make Clones of the Brick 102 4 Add the Brick Sprite 102 5 Clone the Brick Sprite 102 COnTEnTS In DETAIL xi
E Make the Ball Bounce Off Bricks 104 6 Add the Bounce Code to the Brick Sprite 104 F Make You Win and Game Over Messages 105 7 Modify the Tennis Ball Sprite’s Code 105 8 Create the Game Over Sprite 106 9 Create the You Win Sprite 107 The Complete Program 108 Version 2 0 Polishing Time 109 Draw a Cool Backdrop 110 Add Music 111 Make the Paddle Flash When Hit 112 Add an Animated Entrance and Exit to the Bricks 112 Add a Sound Effect to the Brick Exit 115 Add a Sound Effect to the Tennis Ball 117 Add a Trail Behind the Tennis Ball 117 Add an Animated Entrance for the Game Over Sprite 119 Add an Animated Entrance for the You Win Sprite 120 Summary 122 Review Questions 123 6 Snaaaaaake 125 Sketch Out the Design 127 A Make a Snake Head That Moves Around 127 1 Create the Head Sprite 128 Explore when key pressed vs if key pressed then 130 B Make Apples Appear 131 2 Add the Apple Sprite 131 C Make a Body That Appears Behind the Snake Head 132 3 Create the Body Sprite 132 4 Create the Body Sprite’s Second Costume 133 5 Add the Code for the Body Sprite 133 6 Detect Whether the Snake Crashes into Itself or a Wall 135 The Complete Program 137 Version 2 0 Add Bonus Fruit 138 Cheat Mode Invincibility 140 Modify the Head 140 Modify the Body Code 141 Cheat Mode Chop Off Your Tail 142 Summary 142 Review Questions 143 xii COnTEnTS In DETAIL
7 Fruit Slicer 145 Sketch Out the Design 147 A Make the Start Screen Backdrop 148 1 Draw the Backdrops 148 2 Add the Code for the Stage 150 B Make the Slice Trail 151 3 Draw the Slice Sprite 151 Explore Making Lists 152 4 Create Lists and Variables for the Slice Sprite 155 5 Record the Mouse Movements 156 6 Make a Custom Block to Draw the Slice 157 C Make the Begin Button 160 7 Create the Begin Button Sprite 160 D Make the Fruit and Bombs Throw Themselves 162 8 Create the Fruit Sprite 163 9 Make the Sliced Fruit Costumes 164 10 Add the Code to the Fruit Sprite 167 11 Add the Code for the Fruit Sprite’s Clones 170 E Make the Health Sprites 173 12 Create the Health Sprite 173 F Make the Game’s Ending 176 13 Create the White Fade Out Sprite 176 Version 2 0 High Score 179 Cheat Mode Recover Health 180 Summary 181 Review Questions 182 8 Asteroid Breaker in Space 183 Sketch Out the Design 184 A Make a Spaceship That Is Pushed Around 186 1 Create the Spaceship Sprite 186 B Make the Spaceship Wrap Around the Edges 188 2 Add the Wrap-Around Code to the Spaceship Sprite 188 3 Add the Random-Push Code to the Spaceship Sprite 190 C Aim with the Mouse and Fire with the Spacebar 190 4 Create the Energy Blast Sprite 191 D Make Asteroids That Float Around 194 5 Create the Asteroid Sprite 194 COnTEnTS In DETAIL xiii