Learning to Program by Making a Game06 Dec 2020
This year, Computer Science Education Week will be December 7-13, 2020. In honor of CS Education Week, I wanted to write this blog post about the first computer game I wrote, and what I learned along the way. I was about thirteen, and this story picks up near where I left off in my previous blog post about my first computer program. When I wrote that blog post in 2017, I was working mostly from memory. Since then, I actually found an old floppy disk with my game on it. And finding that old floppy disk got me thinking about about how much I learned from writing computer games in my childhood, and how much others might be able to learn from writing their own first computer games today.
At a young age, I became fascinated with computers because by programming, you can make something from nothing. You don’t need to pay money for a new Lego set, and you don’t need a trip to the craft shop or the hardware store. You don’t need any building material. With computers, you can make something that’s interesting and valuable with just your brain. Most thirteen-year-olds probably just want to play computer games, but I wanted to build my own.
Building Games with Game Maker
My desire to build my own computer game led me to a piece of software called Game Maker. This software made it relatively easy to program computer games from scratch. At least, easy enough that a thirteen-year-old could figure it out. Although it wasn’t quite as easy as the drag-and-drop programming Scratch provides today, the principles were largely the same. In Game Maker, you create rooms and objects, and the objects can display as sprites. Game Maker provides a UI for programming the game by making the objects respond to different events. You can make objects move by responding to keyboard events, and you can make objects interact with each other by responding to collision events. The combination of these inputs and interactions makes a complete game.
When I was a young teenager, Game Maker was the perfect program to satisfy my curiosity about programming video games. It was relatively easy to learn, but it was also very powerful. I wanted to program a multiplayer game so several people could play at once on the same machine, like a Nintendo or a PlayStation. My idea was simple – I was going to program a computer version of the playground game “tag”. Fortunately for me, the logic for a tag game isn’t too complex. Each player needs to be able to move, and you need to know when someone runs into someone else. A perfect programming challenge for a young teenager!
Programming Games Is… Educational?
Yes! Programming computer games can be very educational! As a lot of research around project based learning shows, there’s no better way to learn something than to jump right in and do it. By getting into a project a little outside your comfort zone, you quickly realize what you don’t know and you’re motivated to learn so you can finish your project. You’ll remember what you’ve learned better too because you understand how to apply it. Project based learning can be significantly more effective than other forms of education.
Today, there are a variety of platforms that people (both young and old) can use to make their own games while building skills in software development. Scratch is probably the easiest to get started with and also the most well-known. Unfortunately, I’ve personally known a few kids who developed a bad impression of Scratch at a young age. Their first experience with it might have been a silly project that they didn’t like, or perhaps they only used it for animations in the past (which they weren’t interested in). Scratch isn’t limited to silly animations or simple programming like making a robot follow a path. Advanced Scratch projects can be very complex and look like “real” video games – see Flappy Bird, The Crusty Quest, or Chess. So while programming games won’t appeal to everyone, most kids get excited when they see what Scratch can do. I’ve taught an Hour of Code for several years using Scratch (usually with some variation of a simple game) and every single time the kids get excited when they see my game and realize they’re going to be given the tools and knowledge to build their own.
Fundamentally, Scratch works with all the same principles I used when I made my first game in Game Maker. You create a scene, you put objects in the scene, and you program those objects to respond to input and events. I even re-wrote my tag game (the one I made with Game Maker) in Scratch, just to prove to myself that it wouldn’t be hard to do. In addition to that, I’ve written an asteroids game, a drawing program, a platform game, and a simple Frogger clone. I designed most of these as part of lessons I was teaching, but the important thing is that any of these games could be written by a motivated 5th grader. When I wrote these projects, my goal was to make a fun game with simple code that’s easy to understand. Scratch lets you look at the code behind any game, and the code for most of mine is usually no more than about 50 lines long (take a look)! This makes it easy to modify other people’s projects (turn Asteroids into Dodgeball) or learn from them to make your own!
Of course, in addition to Scratch, there are several other more advanced tools available. At some point, Scratch becomes too limiting and too boring, and you want to build better things with more advanced tools. MIT App Inventor uses the same kind of programming blocks that Scratch uses, but provides a wider variety of blocks and allows you to create phone apps that will actually run on real phones. It’s a great tool to move on to when you get bored with Scratch! Alternatively, you could give GDevelop a try. GDevelop is a much more advanced tool for building real computer games, but it operates on many of the same of the program I used back in 2003. No matter what tool you’re using, finding a good tutorial (either written or on YouTube) isn’t a bad place to start.
Building computer games can be as fun as playing them, and I hope I’ve inspired you (or your children!) to try building something and to learn something new along the way! If you like my Scratch games, come follow me on Scratch!