114 THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE
Now all that’s left to do is to invite your friends to play spot-the-difference – and to make
sure the speakers are turned up, of course!
Project 3: RPG Maze
Now you’re getting the hang of Python, it’s time to use Pygame to make something a little
more complicated: a fully-functional text-based maze game, based on classic role-playing
games. Known as text adventures or interactive fiction, these games date back to when
computers couldn’t handle graphics but still have their fans who argue that no graphics will
ever be as vivid as those you have in your imagination!
This program is quite a bit more complex than the others in this chapter, so to make things
easier you will start with a version already partially written. Open the Chromium Web Browser
and go to the following address: rpf.io/rpg-code.
Right-click on the page and click ‘Save as...’. Click the Save button, then click the Load icon
in Thonny. Find the file you just downloaded, rpg-rpg.py, and click the Load button.
Start by clicking the Run icon to familiarise yourself with how a text adventure works. The
game’s output appears in the shell area at the bottom of the Thonny window; make the Thonny
window larger by clicking on the maximise button to make it easier to read.
The game, as it stands now, is very simple: there are two rooms and no objects. The player
starts in the Hall, the first of the two rooms. To go to the Kitchen, simply type ‘go south’
followed by the ENTER key (Figure 5-17). When you’re in the Kitchen, you can type ‘go north’ to
return to the Hall. You can also try typing ‘go west’ and ‘go east’, but as there aren’t any rooms
in those directions the game will show you an error message.
CHALLENGE: ALTER THE LOOK
Can you change the images to make the prank more
appropriate for other events, like Christmas? Can you draw
your own spot-the-difference and scary images (using a
graphics editor such as GIMP)? Could you track the user
clicking on a difference, to make it more convincing?
ONLINE PROJECT
This project is also available online at rpf.io/python-rpg