Scratch Programming Playground: Learn to Program by Making Cool Games

Scratch Programming Playground: Learn to Program by Making Cool Games

by Al Sweigart

Paperback

$22.46 $24.95 Save 10% Current price is $22.46, Original price is $24.95. You Save 10%.
View All Available Formats & Editions
Choose Expedited Shipping at checkout for guaranteed delivery by Friday, March 22

Product Details

ISBN-13: 9781593277628
Publisher: No Starch Press
Publication date: 09/30/2016
Pages: 288
Sales rank: 307,934
Product dimensions: 7.00(w) x 9.10(h) x 0.90(d)
Age Range: 10 - 13 Years

About the Author

Al Sweigart is a software developer and teaches programming to kids and adults. He has written several Python books for beginners, including Automate the Boring Stuff with Python, Invent Your Own Computer Games with Python, and Making Games with Python & Pygame.

Table of Contents

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

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 Bail Sprite 99

Explore: Cloning 101

D Make Clones of the Brick 102

4 Add the Brick Sprite 102

5 Clone the Brick Sprite 102

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 us. 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

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

E Make Asteroids Split in Two When Hit 196

6 Add the Asteroid's Splitting Code 196

7 Add the Asteroid Blasted Message Code to the Energy Blast Sprite 198

F Keep Score and Make a Timer 199

8 Create the Out of Time Sprite 199

G Make the Spaceship Explode If It Is Hit 200

9 Upload the Explosion Sprite 201

10 Add the Code for the Explosion Sprite 201

11 Add the Explode Code to the Spaceship Sprite 202

Version 2.0: Limited Ammo 204

Cheat Mode: Starburst Bomb 206

Summary 207

Review Questions 208

9 Making an Advanced Platform 209

Sketch Out the Design 210

A Create Gravity, Falling, and Landing 212

1 Create the Ground Sprite 212

2 Add the Gravity and Landing Code 213

3 Make the Cat Walk and Wrap Around the Stage 215

4 Remove the Ground Lift Delay 216

B Handle Steep Slopes and Walls 218

5 Add the Steep Slope Code 218

C Make the Cat Jump High and Low 222

6 Add the Jumping Code 222

D Add Ceiling Detection 224

7 Add a Low Platform to the Ground Sprite 224

8 Add the Ceiling Detection Code 225

E Use a Hitbox for the Cat Sprite 228

9 Add a Hitbox Costume to the Cat Sprite 229

10 Add the Hitbox Code 230

F Add a Better Walking Animation 231

11 Add the New Costumes to the Cat Sprite 232

12 Create the Set Correct Costume Block 233

G Create the Level 239

13 Download and Add the Stage Backdrop 239

14 Create a Hitbox Costume for the Ground Sprite 240

15 Add the Ground Sprite's Code 241

16 Add More Wrap-Around Code to the Cat Sprite 242

H Add Crab Enemies and Apples 243

17 Add the Apple Sprite and Code 244

18 Create the Crab Sprite 245

19 Create the Enemy Artificial Intelligence 246

20 Add the Time's Up Sprite 250

Summary 252

Review Questions 253

Where to Go From Here 255

Index 257

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

Scratch Programming Playground: Learn to Program by Making Cool Games 5 out of 5 based on 0 ratings. 1 reviews.
Zombo More than 1 year ago
Let me preface this review by stating that I am not a coder, at all. Although I have an extensive background in Linux, servers, hardware and hosting, coding is something I have steered away from, mostly due to never finding a project that was fun or a method/language that made it engaging and easy to learn. Then came Al Sweigart and his newest offering Scratch Programming Playground: Learn to Program by Making Cool Games. In this finely written and clearly illustrated tome, the author takes the reader through and introduction Scratch (an interactive online programming interface found at http://scratch.mit.edu), becoming familiar with the interface, learning about the structure of building Scratch code and then with little fanfare, gets the reader going with actual coding. Once I had learned how to download the offline Scratch editor, I was off to the races with the very first game to code, a basic graphic game displaying rainbow lines in the code window. This simply whetted my appetite and was simple enough to encourage me to play more with the code to make other things happen. Keep in mind, this is is coming from an adult with NO coding experience and the positive feedback from the tinkering got me to feeling that even I could make something fun all on my own! The further you get into the book, the more concepts the author brings to the table, and shows you in practical means how to implement these concepts in the next few games. Each chapter also shows enhancements to the basic simple game you create, and includes challenges and questions for you to test out your skills gained in the chapter — the simple joy I got from successfully creating a game tweak offered as a challenge was rewarding and encouraging, something a budding programmer of any age will embrace. The later chapters cover concepts that one wouldn’t expect to see in an interface and language like Scratch, yet, there they are; true math functions, Boolean functions that apply to anything (pretty much), multiple variables and implementing controls (keyboard, mouse clicks). By the time I had finished the last game example in the book (a really slick version of a platform game ala Super Mario Bros.), I felt comfortable enough and was brimming with confidence to the point I decided to re-write a flash game a friend wrote some years ago. While I’ve not gotten incredibly far with it yet, my little character walks around, looks as great as he did in flash, and most importantly, I’m having genuine fun developing a game! The author’s presentation is clear, concise, engaging and most of all, makes learning Scratch fun. I honestly would have no problems taking this book and giving to a 8-16 year old and watching them blossom, although a younger child would likely need more basic tools to get started. I have a dear friend whose child is just starting in Scratch (there’s a local club!) - I’ll be getting them a copy so they both can enjoy this book as much as I have!