Figure 4 The command line window 4 Pygame Zero should start to install It will take a few moments and 5 you’ll know it’s finished when your prompt appears again If you get an error message saying that pip is not recognized try installing installing Python again You can uninstall Python first by running the installation installation program again or using the Windows Control panel Make sure you select the box for the PATH when installing Python see Figure 2 After you have reinstalled Python try installing Pygame Zero again 6 When Pygame Zero has finished downloading and you can type again enter the following echo print Hello test py 7 This line creates a new file called test py that contains the instruction print Hello I’ll explain the print instruction in Chapter 1 but for now this is just a quick way to make a test file Be careful when you enter the parentheses curved brackets and quotation marks if you miss one the file won’t work properly 8 Open the test file by entering the following pgzrun test py 9 After a short delay a blank window should open with the title Pygame Zero Game Click the command line window again to bring it to the front you should see the text Hello Press ctrl-C in the command line window to stop the program 10 If you want to delete your test program enter del test py Installing the Software on other Machines Python and Pygame Zero are available for other computer systems Pygame Zero has been designed in part to enable games to work across different computers so the Escape code should run wherever Pygame Zero runs This book only provides guidance for users of Windows and Raspberry Pi computers computers But if you have a different computer you can download Python at https www python org downloads and can find advice on installing Pygame Zero at http pygame-zero readthedocs io en latest installation html 6 Introduction
downloading the Game Files I’ve provided all the program files sounds and images you need for the Escape game You can also download all the listings in the book so if you can’t get one to work you can use mine instead All the book’s content downloads as a single ZIP file called escape zip downloading and unzipping the Files on a raspberry Pi To download the game files on a Raspberry Pi follow these steps and refer to Figure 5 The numbers in Figure 5 show you where to do each step u Open your web browser and visit https nostarch com missionpython Click the link to download the files v From your desktop click the File Manager icon on the taskbar at the top of the screen w Double-click your Downloads folder to open it x Double-click the escape zip file y Click the Extract Files button to open the Extract Files dialog box z Change the folder that you’ll extract to so it reads home pi escape Ensure that the option is selected to Extract files with full path Click Extract Figure 5 The steps you should take to unzip your files Introduction 7
unzipping the File on a Windows Pc To unzip the files on a Windows PC follow these steps 1 Open your web browser and visit https nostarch com missionpython Click the link to download the files Save the ZIP file on your desktop in your Documents folder or somewhere else you can easily find it 2 Depending on the browser you’re using the ZIP file might open automatically automatically or there might be an option to open it at the bottom of the screen If not hold down the Windows Start key and press E The Windows Explorer window should open Go to the folder where you saved the ZIP file Double-click the ZIP file 3 Click Extract All at the top of the window 4 I recommend that you create a folder called escape in your Documents folder and extract the files there My documents folder is C Users Sean Documents so I just typed escape at the end of the folder name to create a new folder in that folder see Figure 6 You can use the Browse button to get to your Documents folder first if necessary 5 Click Extract Figure 6 Setting the folder to unzip the game files into What’s in the ZIP File The ZIP file you’ve just downloaded contains three folders and a Python program escape py see Figure 7 The Python program is the final version of the Escape game so you can start playing it right away The images folder contains all the images you’ll need for the game and other projects in this book The sounds folder contains the sound effects 8 Introduction
In the listings folder you’ll find all the numbered listings in this book If you can’t get a program to work try my version from this folder You’ll need to copy it from the listings folder first and then paste it in the escape folder where the escape py program is now The reason you do this is because the program needs be alongside the images and sounds folders to work correctly Figure 7 The contents of the ZIP file as they might appear in Windows running the Game When you downloaded Python another program called IDLE will have been downloaded with it IDLE is an integrated development environment environment IDE which is software you can use to write programs in Python You can run some of the listings in this book from the IDLE Python editor using the instructions provided Most of the programs though use Pygame Zero and you have to run those programs from the command line Follow the instructions here to run the Escape game and any other Pygame Zero programs running Pygame Zero Programs on the raspberry Pi If you’re using a Raspberry Pi follow these steps to run the Escape game 1 Using the File Manager go to your escape folder in your pi folder 2 Click Tools on the menu and select Open Current Folder in Terminal or you can press F4 The command line window also known as the shell should open as shown in Figure 8 You can enter instructions here for managing files or starting programs Figure 8 The command line window on the Raspberry Pi 3 Type in the following command and press enter The game begins pgzrun escape py Introduction 9