Installing the Software on raspberry Pi If you’re using a Raspberry Pi Python and Pygame Zero are already installed You can skip ahead to Downloading the Game Files on page 7 Installing Python on Windows To install the software on a Windows PC follow these steps 1 Open your web browser and visit https www python org downloads 2 At the time of this writing 3 7 is the latest version of Python but Pygame isn’t available for easy installation on it yet I recommend you use the latest version of Python 3 6 instead 3 6 6 at the time of writing writing You can find old versions of Python farther down the screen on the downloads page see Figure 1 Save the file on your desktop or somewhere else you can easily find it Pygame Zero works only with Python 3 so if you usually use Python 2 you’ll need to switch to Python 3 for this book Figure 1 The Python downloads page 3 When the file has downloaded double-click it to run it 4 In the window that opens select the checkbox to Add Python 3 6 to PATH see Figure 2 5 Click Install Now 4 Introduction
Figure 2 The Python installer 6 If you’re asked whether you want to allow this application to make changes to your device click Yes 7 Python will take a few minutes to install When it finishes click Close to complete the installation Installing Pygame Zero on Windows Now that you have Python installed on your computer you can install Pygame Zero Follow these steps 1 Hold down the Windows Start key and press R The Run window should open see Figure 3 2 Enter cmd see Figure 3 Press enter or click OK Figure 3 The Windows Run dialog box 3 The command line window should open as shown in Figure 4 Here you can enter instructions for managing files or starting programs Enter pip install pgzero and press enter at the end of the line Introduction 5
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