Mission Python: Errata and Updates

21 January 2019


My book Mission Python went through extensive quality controls before publication, with each listing built and tested by both myself and the tech editor. My own testing was carried out on both the Raspberry Pi and the Windows PC. I have played the game to completion many times, in addition to testing each listing as the game was built for the book.

However, I have been alerted to a few minor inaccuracies in the book, mainly in the instructions for running the code. There were also some tiny mistakes in the code (but nothing that stopped the game working).

I use this blog post to maintain a list of any errors and updates. We are incorporating these into the book when it is reprinted. If you got your copy recently, you may not have these issues.

  • My recommendation for installing Python and Pygame Zero is now to use the Mu Editor, which includes Pygame Zero and is available for Windows and macOS. On Raspberry Pi, use Thonny, which also supports Pygame Zero by default. Thonny is installed when you use Raspberry Pi OS with recommended applications. Using Mu or Thonny solves any challenges around installing Pygame Zero, while ensuring you have a version of Python that is compatible. When you run Mu, click Mode to check it’s on Pygame Zero mode. Enter your program in the big window, and then click the Play button to run it.
  • The instructions for running Listing 4-1 say that you can run it from IDLE. This will generate an error saying that the name 'images' is not defined. To run this listing, you need to run it from the command line using pgzrun listing4-1.py. For instructions on using the command line to run Pygame Zero programs, please see the Running the Game section in the book's Introduction. When you run this program, the game window will be blank because the program sets up the data but doesn't display anything on the screen yet. If you don't see any error messages and you do see a blank window, your program is working fine. (When you reach Listing 4-3, you should start to see the room on the screen in the window.)
  • The points made above also apply to Listing 4-2: you should run it using pgzrun listing4-2.py and not IDLE. The game window will be blank. You can't use the shell to test the program, but you can add instructions to the end of the program and then run it from the command line. You will see the output in the command line window. Below is some example code to add to the end of Listing 4-2 to complete Training Mission #1 in Chapter 4. Add this code right at the end of the listing, without any indentation. When you've finished testing, make sure you delete this test code to avoid any problems later on.
    ## Test code ##
    current_room = 45
    generate_map()
    print(room_map)
  • On p118, in Listing 7-5, add the instruction generate_map() as shown below. If you need to make this change, you don't need to use Listing 8-3 in the book, which adds this instruction later. In later listings, the generate_map() instruction should come before the clock.schedule_interval() instruction where shown.
    ###############
    ##   START   ##
    ###############
    
    generate_map()
    clock.schedule_interval(game_loop, 0.03)
  • In Listing 8-2, the PLAYER_SHADOW dictionary uses animation frame 3 twice. The final image in the left dictionary should be images.spacesuit_left_4_shadow, for example, instead of images.spacesuit_left_3_shadow again. The same applies to the right, up, and down animation sequences.
  • On p164 in Listing 9-8, you can make the inventory easier to use by adding a delay to stop it cycling through the items too fast. After the display_inventory() instruction, add a time.sleep(0.2) instruction. This should be indented to the same depth as the display_inventory() instruction.
  • On p178, when you add the code from Listing 10-6 to Listing 10-5, you should save the program as listing10-6.py and run it with pgzrun listing10-6.py. The process and program still works if you reuse the listing10-5.py filename again as described in the book, but the correct process is to use listing10-6.py.
  • You can run Pygame Zero programs directly from IDLE by adding two lines to the code. As the first line, add:
    import pgzrun
    As the final line, add:
    pgzrun.go()
  • There are two recipes in the code that are not required. They are hangovers from an earlier version of the game in which you began the game outside the spacesuit and had to repair it before you could wear it. The two recipes are [88, 58, 89] and [89, 60, 90]. This doesn't affect how the game plays: because objects 88 and 89 are not in the game, you can't use the recipe. If you were to add objects 88 and 89 when customising the game, and players were to try using them together with objects 58 and 60 respectively, you would see unexpected results.
  • If you're having difficulties getting the code running, I recommend you download and test my version of the code to see whether the problem still exists. If not, look for differences between your code and mine. In particular, indentation can be hard to spot and makes a difference to how the code works. If you can't get my code working, I recommend you try using Mu Editor on macOS or Windows, because it installs Pygame Zero for you and problems sometimes arise installing it in other ways. On the Raspberry Pi desktop, Pygame Zero is installed for you and you can use the Thonny Python editor.

If you experience difficulties, please see also my blog post about compatibility with different software and hardware platforms to those officially supported by Mission Python.

Many thanks to Adriaan van Niekerk, Stéphanie Noardo, Richard Park, Tim Byers, Ryan McLeod, Matt Schottel, Chris Myrick, and Barry Groden for telling me about these issues.

If you encounter other problems, please feel free to get in touch. We are incorporating these updates and corrections into the ebook and reprints of the paper book.

Permanent link for this post | Blog Home | Website Home | Email feedback


Dip into the blog archive

June 2005 | September 2005 | January 2006 | March 2006 | April 2006 | May 2006 | June 2006 | July 2006 | August 2006 | September 2006 | October 2006 | November 2006 | December 2006 | February 2007 | March 2007 | April 2007 | May 2007 | June 2007 | July 2007 | August 2007 | September 2007 | October 2007 | November 2007 | December 2007 | January 2008 | February 2008 | March 2008 | April 2008 | May 2008 | June 2008 | July 2008 | August 2008 | September 2008 | October 2008 | November 2008 | December 2008 | January 2009 | February 2009 | March 2009 | April 2009 | May 2009 | June 2009 | July 2009 | August 2009 | September 2009 | October 2009 | November 2009 | December 2009 | January 2010 | February 2010 | March 2010 | April 2010 | May 2010 | June 2010 | August 2010 | September 2010 | October 2010 | November 2010 | December 2010 | March 2011 | April 2011 | May 2011 | June 2011 | July 2011 | August 2011 | September 2011 | October 2011 | November 2011 | December 2011 | January 2012 | February 2012 | March 2012 | June 2012 | July 2012 | August 2012 | September 2012 | October 2012 | December 2012 | January 2013 | February 2013 | March 2013 | April 2013 | June 2013 | July 2013 | August 2013 | September 2013 | October 2013 | November 2013 | December 2013 | January 2014 | February 2014 | March 2014 | April 2014 | May 2014 | June 2014 | July 2014 | August 2014 | September 2014 | October 2014 | November 2014 | December 2014 | January 2015 | February 2015 | March 2015 | April 2015 | May 2015 | June 2015 | September 2015 | October 2015 | December 2015 | January 2016 | February 2016 | March 2016 | May 2016 | July 2016 | August 2016 | September 2016 | October 2016 | November 2016 | December 2016 | January 2017 | July 2017 | August 2017 | October 2017 | November 2017 | January 2018 | February 2018 | August 2018 | October 2018 | November 2018 | December 2018 | January 2019 | March 2019 | June 2019 | August 2019 | September 2019 | October 2019 | January 2020 | February 2020 | March 2020 | April 2020 | May 2020 | June 2020 | September 2020 | October 2020 | December 2020 | January 2021 | February 2021 | May 2021 | June 2021 | October 2021 | November 2021 | December 2021 | January 2022 | February 2022 | March 2022 | May 2022 | July 2022 | August 2022 | September 2022 | December 2022 | March 2023 | April 2023 | May 2023 | June 2023 | October 2023 | November 2023 | January 2024 | February 2024 | May 2024 | June 2024 | July 2024 | September 2024 | October 2024 | November 2024 | December 2024 | Top of this page | RSS

Credits

© Sean McManus. All rights reserved.

Visit www.sean.co.uk for free chapters from Sean's coding books (including Mission Python, Scratch Programming in Easy Steps and Coder Academy) and more!

Discover my latest books

100 Top Tips: Microsoft Excel

100 Top Tips: Microsoft Excel

Power up your Microsoft Excel skills with this powerful pocket-sized book of tips that will save you time and help you learn more from your spreadsheets.

Scratch Programming in Easy Steps

Scratch Programming IES

This book, now fully updated for Scratch 3, will take you from the basics of the Scratch language into the depths of its more advanced features. A great way to start programming.

Mission Python book

Mission Python

Code a space adventure game in this Python programming book published by No Starch Press.

Cool Scratch Projects in Easy Steps book

Cool Scratch Projects in Easy Steps

Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!

Raspberry Pi For Dummies

Raspberry Pi For Dummies

Set up your Raspberry Pi, then learn how to use the Linux command line, Scratch, Python, Sonic Pi, Minecraft and electronics projects with it.

Earworm

Earworm

In this entertaining techno-thriller, Sean McManus takes a slice through the music industry: from the boardroom to the stage; from the studio to the record fair.

Walking astronaut from Mission Python book Top | Search | Help | Privacy | Access Keys | Contact me
Home | Newsletter | Blog | Copywriting Services | Books | Free book chapters | Articles | Music | Photos | Games | Shop | About