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.