Scratch Programming Playground: Learn to Program by Making Cool Games
BRIEF CONTENTS Acknowledgments xvii Introduction xix Chapter 1 Getting Started with Scratch 1 Chapter 2 Rainbow Lines in Space 15 Chapter 3 Maze Runner 35 Chapter 4 Shooting Hoops with Gravity 67 Chapter 5 A Polished Brick Breaker Game 93 Chapter 6 Snaaaaaake 125 Chapter 7 Fruit Slicer 145 Chapter 8 Asteroid Breaker in Space 183 Chapter 9 Making an Advanced Platformer 209 Where to Go from Here 255 Index 257
CONTENTS IN DETAIL Acknowledgments xvii Introduction xix Who This Book Is For xx About This Book xxi How to Use This Book xxii Online Resources xxiii Errata and Updates xxiii 1 Getting Started with Scratch 1 Running Scratch 3 The Offline Editor 4 The Scratch Editor and Sprites 4 The Paint Editor 6 Working with Code Blocks 8 Adding Blocks 8 Deleting Blocks 9 Running Programs 10 Showing Off Your Programs 11 Getting Help 11 The Tips Window 12 The See Inside Button 13 Summary 14 2 Rainbow Lines in Space 15 Sketch Out the Design 16 A Create the Space Backdrop 18 1 Clean Up and Set the Stage 18 B Create Three Bouncing Dots 20 2 Paint the Dot 20 3 Add Code for the Dot 1 Sprite 22 Explore Directions and Degrees 23 4 Duplicate the Dot 1 Sprite 25 C Draw the Rainbow Lines 25 5 Add the Code for the Drawing Dot Sprite 25
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