Playing video games is fun, but programming your own video games is a creative, challenging skill that will let you make your own fun. The free Scratch programming environment gives everyone an easy way to learn programming skills. While Scratch is primarily designed for 8- to 16-year-olds, it’s used by people of all ages, including younger children with their parents and college students learning their first programming language.
There’s so much that you can do with Scratch, it’s hard to know where to start. That’s where this book comes in. This book guides you through creating several video games in Scratch. By building the projects in this book, you’ll get a good idea of which blocks are commonly used to create video games in Scratch. These projects provide a solid foundation for you to build upon when creating your own original programs.
WHO THIS BOOK IS FOR
No previous programming experience is necessary to read this book. The only mathematics skills required are basic arithmetic: addition, subtraction, multiplication, and division. Don’t let math phobia prevent you from learning to program. And don’t forget that the computer will perform calculations for you!
Each program in the book is easy to make by following the step-by-step instructions. You’ll learn about the code blocks and programming concepts as you make games that use them. No matter your skill level, there’s no reason you can’t start reading this book now!
Kids can follow along with the activities on their own, but this book is also for parents, teachers, and volunteers who want to introduce their children or students to the world of programming. The projects are ideal for a weekend activity or afterschool computer club. Adults don’t have to be software engineers to use this book to help others learn.
If you want a thorough guide to all of Scratch’s features, I recommend the book Learn to Program with Scratch by Majed Marji (No Starch Press, 2014) to supplement this one. You can also watch video tutorials online at https://scratch.mit.edu/help/videos/ and https://inventwithscratch.com/.
But programming is a hands-on skill like karate or guitar: you can’t learn it by reading alone! Make sure you’re following along and creating the games—you’ll learn a lot more that way.
ABOUT THIS BOOK
Each chapter walks you through programming a single game, and programming concepts are explained as they come up. You’ll start by sketching out what the final game will look like and planning the main parts of the parts of the program. The sections that follow will cover how to code each of these parts step-by-step until you’ve built the full game. After building the main game, you’ll have the option of adding special features and cheat modes. Review questions at the end of each chapter help you check whether you understand the topics covered.
Chapter 1: Getting Started with Scratch shows you how to access the Scratch website and the different parts of the Scratch editor.
In Chapter 2: Rainbow Lines in Space!, you’ll create an animated art project using basic code blocks and several sprites working together. You’ll also learn about directions and degrees.
In Chapter 3: Maze Runner, you’ll make a maze game in which the player uses the keyboard to change the cat’s coordinates and guide it through eight different maze levels.
Chapter 4: Shooting Hoops with Gravity shows you how to make a basketball game that implements realistic gravity for jumping cats and falling basketballs.
Chapter 5: A Polished Brick Breaker Game covers simple techniques for taking a plain brick breaker game and turning it into a polished, exciting game with animations, sound effects, and more.
Chapter 6: Snaaaaaake! features the classic computer game in which the player guides an ever-growing snake around the screen. It explains how to use Scratch’s sprite cloning feature to make the stretching snake body.
In Chapter 7: Fruit Slicer, you’ll make a clone of the hit smartphone game Fruit Ninja, in which the player slices fruit in mid-air.
Chapter 8: Asteroid Breaker . . . in Space! features a clone of the classic space shooter Asteroids. You’ll add mouse and keyboard controls to the spaceship.
Pulling together many of the concepts used in previous chapters, Chapter 9: Making an Advanced Platformer explains how to create a platformer game with walking and jumping animations, platforms, and AI-controlled enemies.
HOW TO USE THIS BOOK
All of the book’s projects start with a sketch of the game we’ll make. The labels on the sketch point to features that we’ll add to the game with code.
To keeps things manageable, we’ll tackle each part of the game one at a time. The blue ABC headings in the book correspond to these features in the sketch.
Splitting a big problem into a bunch of little problems can really help organize your thinking and make a big problem feel approachable. After we get a simple version of the game up and running, we’ll add new features, cheat codes, and more. When you’re ready to start creating games yourself, I recommend starting with a simple sketch.
Although the Scratch environment includes many images, you’ll need some extra files to make the projects in this book. These files are in the resources ZIP file, which you can download from https://www.nostarch.com/scratchplayground/. You’ll need to unzip the files to your hard drive to access them.
The resources ZIP file contains the image files used in the book’s projects and the skeleton project files for each of the programs. These skeleton project files have all the setup steps already completed and only require you to add the code blocks. If you are having trouble finishing your program, you can try starting from the skeleton project file instead of a brand new, blank project. Using the skeleton project files may be a good idea if you are a teacher who is coaching several students and time is limited, because they’ll only have to add the code blocks to complete the program.
ERRATA AND UPDATES
While we’ve done our best to keep this book error free, corrections and updates for this book will be listed at https://nostarch.com/scratchplayground/.