Program Arcade Games: With Python and Pygame, Fourth Edition

Book description

Learn and use Python and PyGame to design and build cool arcade games. In Program Arcade Games: With Python and PyGame, Fourth Edition, Dr. Paul Vincent Craven teaches you how to create fun and simple quiz games; integrate and start using graphics; animate graphics; integrate and use game controllers; add sound and bit-mapped graphics; and build grid-based games.

After reading and using this book, you'll be able to learn to program and build simple arcade game applications using one of today's most popular programming languages, Python. You can even deploy onto Steam and other Linux-based game systems as well as Android, one of today's most popular mobile and tablet platforms.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Author
  8. Introduction
  9. Chapter 1: Before Getting Started…
    1. Installing and Starting Python
      1. Windows Installation
      2. Mac Installation
      3. Unix Installation
      4. Optional Wing IDE
    2. Viewing File Extensions
    3. Learn to Make Games and Get Paid
      1. Get the Most from This Book
      2. Send Feedback
  10. Chapter 2: Create a Custom Calculator
    1. Printing
      1. Printing Text
      2. Printing Results of Expressions
      3. Printing Multiple Items
    2. Escape Codes
    3. Comments
    4. Assignment Operators
    5. Variables
    6. Operators
      1. Operator Spacing
    7. Order of Operations
    8. Trig Functions
    9. Custom Equation Calculators
    10. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  11. Chapter 3: What Is a Computer Language?
    1. Short History of Programming
    2. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  12. Chapter 4: Quiz Games and If Statements
    1. Basic Comparisons
    2. Indentation
    3. Using And/Or
    4. Boolean Variables
    5. Else and Else If
    6. Text Comparisons
      1. Multiple Text Possibilities
      2. Case Insensitive Comparisons
    7. Example if Statements
    8. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  13. Chapter 5: Guessing Games with Random Numbers and Loops
    1. for Loops
      1. Counting by Numbers Other Than One
      2. Nesting Loops
      3. Keeping a Running Total
    2. Example for Loops
    3. while Loops
      1. Using Increment Operators
      2. Looping Until User Wants to Quit
      3. Common Problems with while Loops
    4. Example while Loops
    5. Random Numbers
      1. The randrange Function
      2. The random Function
    6. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  14. Chapter 6: Introduction to Graphics
    1. Computer Coordinate Systems
    2. Pygame Library
    3. Colors
    4. Open a Window
    5. Interacting with the User
      1. The Event Processing Loop
      2. Processing Each Frame
    6. Ending the Program
    7. Clearing the Screen
    8. Flipping the Screen
    9. Open a Blank Window
    10. Drawing Introduction
    11. Drawing Lines
    12. Drawing Lines with Loops and Offsets
    13. Drawing a Rectangle
    14. Drawing an Ellipse
    15. Drawing an Arc
    16. Drawing a Polygon
    17. Drawing Text
    18. Full Program Listing
    19. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  15. Chapter 7: Back to Looping
    1. Print Statement End Characters
    2. Advanced Looping Problems
    3. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  16. Chapter 8: Introduction to Lists
    1. Working with Lists
    2. Iterating through a List
    3. Adding to a List
    4. Summing or Modifying a List
    5. Slicing Strings
    6. Secret Codes
    7. Associative Arrays
    8. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  17. Chapter 9: Introduction to Animation
    1. Animating Snow
      1. Code Explanation
      2. Full Program Listing
    2. 3D Animation
    3. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  18. Chapter 10: Functions
    1. Function Parameters
    2. Returning and Capturing Values
      1. Returning Values
      2. Capturing Returned Values
      3. Improving the volume_cylinder Example
    3. Documenting Functions
    4. Variable Scope
    5. Pass-by-copy
    6. Functions Calling Functions
    7. Main Functions and Globals
    8. Short Examples
    9. Mudball Game Example
    10. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Correcting Code
      4. Exercise
  19. Chapter 11: Controllers and Graphics
    1. Mouse
    2. Keyboard
    3. Game Controller
    4. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  20. Chapter 12: Bitmapped Graphics and Sound
    1. Storing the Program in a Folder
    2. Setting a Background Image
    3. Moving an Image
    4. Sounds
    5. Full Listing
    6. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  21. Chapter 13: Introduction to Classes
    1. Why Learn About Classes?
    2. Defining and Creating Simple Classes
    3. Adding Methods to Classes
      1. Example: Ball Class
    4. References
      1. Functions and References
      2. Review Questions
    5. Constructors
      1. Avoid This Mistake
      2. Review Questions
    6. Inheritance
      1. Is-A and Has-A Relationships
    7. Static Variables vs. Instance Variables
      1. Instance Variables Hiding Static Variables
    8. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  22. Chapter 14: Introduction to Sprites
    1. Basic Sprites and Collisions
    2. Moving Sprites
    3. The Game Class
    4. Other Examples
      1. Shooting things
      2. Walls
      3. Platforms
      4. Snake/Centipede
      5. Using Sprite Sheets
    5. Review
      1. Multiple Choice Quiz
      2. Exercise
  23. Chapter 15: Libraries and Modules
    1. Why Create a Library?
    2. Creating Your Own Module/Library File:
    3. Namespace
    4. Third Party Libraries
    5. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
      3. Exercise
  24. Chapter 16: Searching
    1. Reading from a File
    2. Reading into an Array
    3. Linear Search
      1. Linear Search Algorithm
    4. Variations on the Linear Search
      1. Does at Least One Item Have a Property?
      2. Do All Items Have a Property?
      3. Create a List with All Items Matching a Property
    5. Binary Search
    6. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet Linear Search Review
      3. Binary Search Review
      4. Challenge Question
      5. Exercise
  25. Chapter 17: Array-Backed Grids
    1. Application
      1. Drawing the Grid
      2. Populating the Grid
      3. Final Program
    2. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
  26. Chapter 18: Sorting
    1. Swapping Values
    2. Selection Sort
    3. Insertion Sort
    4. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
  27. Chapter 19: Exceptions
    1. Vocabulary
    2. Exception Handling
    3. Example: Saving High Score
    4. Exception Objects
    5. Exception Generating
    6. Proper Exception Use
    7. Review
      1. Multiple Choice Quiz
      2. Short Answer Worksheet
  28. Chapter 20: Recursion
    1. Where Is Recursion Used?
    2. How Is Recursion Coded?
    3. Controlling Recursion Depth
    4. Recursion Factorial Calculation
    5. Recursive Rectangles
    6. Fractals
    7. Recursive Binary Search
    8. Review
      1. Short Answer Worksheet
  29. Chapter 21: Formatting
    1. Decimal Numbers
    2. Strings
    3. Leading Zeros
    4. Floating-Point Numbers
    5. Printing Dollars and Cents
    6. Use in Pygame
    7. Review
      1. Short Answer Worksheet
  30. Chapter 22: Exercises
    1. Exercise 1: Custom Calculators
      1. Program A
      2. Program B
      3. Program C
    2. Exercise 2: Create-a-Quiz
      1. Description
      2. Example Run
    3. Exercise 3: Camel
      1. Description of the Camel Game
      2. Sample Run of Camel
      3. Programming Guide
      4. Hints
    4. Exercise 4: Create-a-Picture
      1. Description
    5. Exercise 5: Loopy Lab
      1. Part 1
      2. Part 2
      3. Part 3
      4. Part 4
    6. Exercise 6: Adventure!
      1. Description of the Adventure Game
      2. Sample Run
      3. Creating Your Dungeon
      4. Step-by-step Instructions
    7. Exercise 7: Animation
      1. Requirements
    8. Exercise 8: Functions
    9. Exercise 9: User Control
    10. Exercise 10: Bitmapped Graphics and User Control
    11. Exercise 11: Classes and Graphics
      1. Instructions
    12. Exercise 12: Sprite Collecting
    13. Exercise 13: Sprite Moving
    14. Exercise 14: Spell Check
      1. Requirements
      2. Steps to Complete:
      3. Example Run
    15. Exercise 15: Final Exercise
      1. Video Game Option
      2. Text Adventure Option
  31. Index

Product information

  • Title: Program Arcade Games: With Python and Pygame, Fourth Edition
  • Author(s):
  • Release date: December 2015
  • Publisher(s): Apress
  • ISBN: 9781484217900