Free download
Reviewed: March 2016
I noticed this book on the Raspberry Pi blog at about the time I met a 9-year-old who is struggling with Pygame, and I was really hoping I’d be able to recommend it to him, especially as it’s an official publication of the charitable Raspberry Pi Foundation, which I’m keen to help. Unfortunately, while I applaud the effort, the cause, and the price, I feel duty-bound to report I was not impressed enough to recommend giving this book to a child.
My worst gripe is how the book treats classes. After having made do with struct-like dictionaries for so long, classes are finally introduced in Chapter 8 with what appears to be a half-hearted attempt to explain why they’re better (is a child who needs the word ‘nemesis’ to be defined really expected to understand ‘it’s not very semantic’ without clarification?) and then the terminology gets more confusing: ‘instantiation’ is mentioned, but it’s not made clear what an ‘instance’ is, and at one point we are told the player ‘is a class’ (not the sole instance of one) and, most confusingly, the player has an init method while the enemies do not: they have a factory function instead, and there’s no explanation for this. But then we are told classes have ‘functions’: it doesn’t even call them ‘member functions’, let alone ‘methods’, so how are we to tell which are inside the class and which are merely associated with it? Some of the design decisions are questionable too: in a shoot-’em-up, each enemy ship tracks its own bullets, then we are told that’s inadequate because we want bullets to persist after ships are destroyed, and the ‘fix’ is to introduce a separate list of ‘left-over bullets’ and write code to transfer ownership of bullets upon a ship’s destruction, but didn’t anyone think of directly placing all bullets onto that list to begin with and doing away with the now-redundant per-ship lists? Or are we teaching children never to replace their earlier code?
In other news, a football held three feet off the ground gets only 1/9th the gravity it has at one foot. That’s not what the physics chapter actually says, but its wording is vague enough to allow that interpretation. It could be fixed by explicitly stating that the distance which matters is that from the earth’s centre, not its surface, but nobody seems to have thought of that. And then there’s this clanger: `alien\'s are gonna kill me'. Yes, that apostrophe is wrong; no, there’s no explanation of the escaping backslash or why we’re putting this in a single-quoted string when all strings around it are double quoted, and no it doesn’t help that quotes to the left of strings are printed as back-quotes without any note saying that’s not what you’re supposed to type (this is supposed to be a beginner’s book).
On the subject of typing-in the listings, why is there so much dependence on sound and graphics files that you have to download separately? Not every child’s Raspberry Pi will have Internet access. Showing how to load an image or play a sound from a file might be good, but, once that’s done, I’d have transitioned swiftly to the kind of simple graphics and sound that children can type in themselves (and customise it as they go) rather than learning that they need to hire artists and professional musicians to do it – which may be true once you become a professional games coder, but why not let children have more fun doing it themselves? Back in the BBC Micro days, making my own sound effects and tunes was half the point!
Finally, there seem to be a fair few unexplained numbers in the middle of the code. I wouldn’t go to the other extreme of creating a variable for everything, but in a book like this I’d expect a few more numbers to be given meaningful names, and perhaps even a little discussion (or at least a mention) of the design issue. The boy I met might just be trying to make a game, but I’m trying to sneak in a lesson or two about good programming practice while he’s at it, and I’m not always sure the book’s on my side.
The book’s filename ends with _v1.pdf, implying this is version 1 and there will be future versions. Let’s hope these address some of the issues. Meanwhile, for this particular boy, I wrote my own ‘chapter’ at http:// people.ds.cam.ac.uk/ssb22/game.html for which I welcome criticism, although my decision to write all prose in Chinese as well as English did limit what I could say. (The book I mentioned on that page was not this one, but one he’d brought from China, and, although his parents are trying to make him go English-only, I felt OOP might be put at a severe disadvantage in that house if it doesn’t get at least one explanation in Chinese to compete with the seductively-Chinese book that doesn’t help. Francis Glassborow’s You Can Do It has been translated into Chinese but might not be accepted by a Pygame enthusiast, and if I’m resorting to writing him something myself then it might as well be bilingual off the bat even if that does result in it getting shortened by my limited Chinese skills.)