Over the last year or so my older son, who is about to turn eight, has spent maybe one morning a month creating a video game using Scratch. This doesn’t seem like a lot of time to spend learning to program, but I’ve been trying to avoid pushing. Our usual mode of operation is that he sits there at one computer while I work at another one; I’ll come over and answer questions or help out if he gets stuck, but he’s basically driving both the design and implementation.
The game is simple: you control an ant that is being chased by a bomb, which blows up the ant if it catches it. The ant cannot move through the walls of a simple maze, but the bomb can. Here the ant is being chased:
Here it got caught:
This morning I asked Jonas if his code used any variables and he asked: What’s a variable? So I explained it would be used to store the number of lives you had left or something like that, and he immediately wanted to give the player multiple lives. The mechanics of doing this was a bit beyond him—this was not only his first variable, but also his first inter-sprite messaging—so we sat down together and implemented it in around half an hour. Adding the reset-board and game-over logic were the most complicated tasks we’ve done so far.
I also tried to tell Jonas how creating a smart adversary is perhaps the hardest aspect of making a good computer game, and that nobody even knows how to make an enemy as smart as he is. Jonas replied that in that case it should be pretty easy to create an enemy as smart as his five years old brother. I think he was joking but it wasn’t totally clear.
Does Scratch have any drawbacks? Perhaps a few. I found the lack of procedural abstraction distracting; Scratch seems to encourage a significant level of code duplication that would grow onerous for any non-simple tasks. Jonas and I both found the concurrent-object execution model to be a bit confusing since it was often not clear where to put a particular piece of code. He ended up putting most of the game logic into the bomb that chases the player around the screen—this worked pretty well, but didn’t seem ideal. We ran into a few interface warts where, for example, a comparison widget seems to encourage you to type the name of a variable into one of its slots, but the resulting code doesn’t work—you rather must drag a widget corresponding to the variable into the comparison object.
Overall Scratch is really well done; I found the programming environment to be enjoyable and Jonas was able to pick up new constructs from the menus and figure them out on his own. The compile-to-Flash feature is totally great since you can execute people’s Scratch projects in the browser.