Continuing my three-part series for Computeractive, in this issue you’ll find a guide to writing a simple arcade game for the Raspberry Pi using Python and the pygame library. It’s rather more in-depth than the magazine would normally cover, but that’s the whole purpose of the Raspberry Pi project after all: to get more people programming, and to dispel the myth that it’s something only a select few can ever attempt.
Those of you with eagle eyes may spot similarities between this issue’s tutorial and the pygame chapter of my book, the Raspberry Pi User Guide. There’s a good reason for that: the programs are the same. The Snake game is a great way to demonstrate game programming: it requires only four inputs – one for each cardinal direction – has a simple scoring mechanism and doesn’t require AI for the enemies. It also teaches a surprising chunk of the Python language, including the concept of stacks – used to store the location of each snake segment.
Next issue, the final part will be branching off from the book in a dramatic way: introducing the idea of building a custom game controller – to control the snake with, naturally – from scratch and connecting it to the Raspberry Pi’s General Purpose Input/Output (GPIO) port. Even if you’ve read the book – and I hope you have – I’d recommend picking up a copy!
Computeractive Issue 382 is available in all good newsagents, most bad ones, and via the Computeractive Direct website.