Mission Python

Book description

Launch into coding with Mission Python, a space-themed guide to building a complete computer game in Python. You'll learn programming fundamentals like loops, strings, and lists as you build Escape!, an exciting game with a map to explore, items to collect, and tricky logic puzzles to solve. As you work through the book, you'll build exercises and mini-projects, like making a spacewalk simulator and creating an astronaut's safety checklist that will put your new Python skills to the test.



You'll learn how to use Pygame Zero, a free resource that lets you add graphics and sound effects to your creations, and you'll get useful game-making tips, such as how to design fun puzzles and intriguing maps. Before you know it, you'll have a working, awesome game to stump your friends with (and some nifty coding skills, too!). You can follow this book using a Raspberry Pi or a Microsoft Windows PC, and the 3D graphics and sound effects you need are provided as a download.

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. ABOUT THE AUTHOR
  6. ABOUT THE TECHNICAL REVIEWER
  7. BRIEF CONTENTS
  8. CONTENTS IN DETAIL
  9. ACKNOWLEDGMENTS
  10. INTRODUCTION
    1. How to Use This Book
    2. What’s in This Book?
    3. Installing the Software
    4. Downloading the Game Files
    5. Running the Game
    6. Playing the Game
  11. 1 YOUR FIRST SPACEWALK
    1. Starting the Python Editor
    2. Introducing the Python Shell
    3. Introducing Script Mode
    4. Creating the Starfield
    5. Stopping Your Pygame Zero Program
    6. Adding the Planet and Spaceship
    7. Are You Fit to Fly?
  12. 2 LISTS CAN SAVE YOUR LIFE
    1. Making Your First List: The Take-Off Checklist
    2. Using Index Numbers
    3. Creating the Spacewalk Checklist
    4. A List of Lists: The Flight Manual
    5. Combining Lists
    6. Making Maps from Lists: The Emergency Room
    7. Are You Fit to Fly?
  13. 3 REPEAT AFTER ME
    1. Displaying Maps with Loops
    2. Loop the Loop
    3. Displaying a 3D Room Image
    4. Understanding How the Room Is Drawn
    5. Working Out Where to Draw Each Item
    6. Are You Fit to Fly?
  14. 4 CREATING THE SPACE STATION
    1. Automating the Map Making Process
    2. How the Automatic Map Maker Works
    3. Creating the Map Data
    4. Writing the GAME_MAP Code
    5. Testing and Debugging the Code
    6. Generating Rooms from the Data
    7. Exploring the Space Station in 3D
    8. Making Your Own Maps
    9. Are You Fit to Fly?
  15. 5 PREPARING THE SPACE STATION EQUIPMENT
    1. Creating a Simple Planets Dictionary
    2. Making the Space Station Objects Dictionary
    3. Are You Fit to Fly?
  16. 6 INSTALLING THE SPACE STATION EQUIPMENT
    1. Understanding the Dictionary for the Scenery Data
    2. Adding the Scenery Data
    3. Adding the Perimeter Fence for the Planet Surface
    4. Loading the Scenery into Each Room
    5. Updating the Explorer to Tour the Space Station
    6. Are You Fit to Fly?
  17. 7 MOVING INTO THE SPACE STATION
    1. Arriving on the Space Station
    2. Adding the Movement Code
    3. Understanding the Movement Code
    4. Moving Between Rooms
    5. Are You Fit to Fly?
  18. 8 REPAIRING THE SPACE STATION
    1. Sending Information to a Function
    2. Adding Variables for Shadows, Wall Transparency, and Colors
    3. Deleting the EXPLORER Section
    4. Adding the DISPLAY Section
    5. Positioning the Room on Your Screen
    6. Making the Front Wall Fade In and Out
    7. Displaying Hints, Tips, and Warnings
    8. Showing the Room Name When You Enter the Room
    9. Are You Fit to Fly?
  19. 9 UNPACKING YOUR PERSONAL ITEMS
    1. Adding the Props Information
    2. Adding Props to the Room Map
    3. Finding an Object Number from the Room Map
    4. Picking Up Objects
    5. Adding the Inventory Functionality
    6. Dropping Objects
    7. Examining Objects
    8. Are You Fit to Fly?
  20. 10 MAKE YOURSELF USEFUL
    1. Adding the Keyboard Control for Using Objects
    2. Adding Standard Messages for Using Objects
    3. Adding the Game Progress Variables
    4. Adding the Actions for Specific Objects
    5. Combining Objects
    6. Adding the Game Completion Sequence
    7. Exploring the Objects
    8. Are You Fit to Fly?
  21. 11 ACTIVATING SAFETY DOORS
    1. Planning Where to Put Safety Doors
    2. Positioning the Doors
    3. Adding Access Controls
    4. Making the Doors Open and Close
    5. Adding the Door Animation
    6. Shutting the Timed Door
    7. Adding a Teleporter
    8. Activating the Airlock Security Door
    9. Removing Exits for Your Own Game Designs
    10. Mission Accomplished?
    11. Are You Fit to Fly?
  22. 12 DANGER! DANGER! ADDING HAZARDS
    1. Adding the Air Countdown
    2. Adding the Moving Hazards
    3. Adding the Toxic Spills
    4. Making the Finishing Touches
    5. Your Next Mission: Customizing the Game
    6. Are You Fit to Fly?
  23. A ESCAPE: THE COMPLETE GAME LISTING
  24. B TABLE OF VARIABLES, LISTS, AND DICTIONARIES
  25. C DEBUGGING YOUR LISTINGS
    1. Indentation
    2. Case Sensitivity
    3. Parentheses and Brackets
    4. Colons
    5. Commas
    6. Images and Sounds
    7. Spelling
  26. INDEX

Product information

  • Title: Mission Python
  • Author(s): Sean McManus
  • Release date: October 2018
  • Publisher(s): No Starch Press
  • ISBN: 9781593278571