Introduction
PART I: IT'S ALL FUN AND GAMES
Chapter 1 Getting Started
Understanding Computer Programming
- What is a computer?
- How do we talk to computers?
- What is Python?
Setting Things Up
- Installing Python
- Installing and Configuring VisualStudio Code
- Creating a Work Folder
Writing Your First Python Program
- Selecting Your Work Folder
- It’s Coding Time!
Summary
Chapter 2 Mad Libs
Understanding Functions
Using Variables
- Creating a Variable
- Using a Variable
- Some Important Variable Rules
- Variables, More Variables, and Even More Variables
- Getting User Input
Playing Mad Libs
- Write Your Story
- Add Variables
- Get User Input
Summary
Chapter 3 Roll the Dice
Using Libraries
- The random Library
- Generating Random Numbers
- Choosing a Random Item
“3” Is Not 3
Commenting Your Code
One Die, Two Dice
Summary
Chapter 4 Calculate the Day
Working with Dates
- The datetime Library
- Using the datetime Class
Making Decisions
- The if Statement
- What else?
- if Revisited
- Testing for Other Options
- Using in
Beating the Mathematician
- Handling Numeric Inputs
- Putting It All Together
- An Alternate Solution
Summary
Chapter 5 Rock Paper Scissors
More Strings
Game Time
- Handling User Input
- The Game Code
- One Last Tweak
Summary
Chapter 6 Secret Codes
Lists
- Creating Lists
- Accessing List Items
- Changing List Items
- Adding and Removing Items
- Finding Items
- Sorting
Loop-de-Loop
- Looping Through Items
- Looping Through Numbers
- Nested Loops
Cracking the Code
- Encrypting Characters
- Modulus Math
- Encryption Code
- Decryption Code
Summary
Chapter 7 Guess the Number
Conditional Loops
Game Time
- The Basic Game
- Putting It All Together
Summary
Chapter 8 Becoming a Coder
How Coders Code
Game Components
- Restricting User Input
- Storing User Guesses
- Displaying Lists
- Masking Characters
Summary
Chapter 8 Becoming a Coder
How Coders Code
Game Components
- Restricting User Input
- Storing User Guesses
- Displaying Lists
- Masking Characters
Summary
Chapter 9 Hangman
Game Time
So How Does It Work?
Summary
Chapter 10 Keep Going
Birthday Countdown
- Program Requirements
- Program Flow
- Some Tips
Tip Calculator
- program requirements
- program flow
- some tips (pun intended)
- Program Requirements
- Program Flow
- Some Tips
Summary
PART II: ON AN ADVENTURE
Chapter 11 Getting Func-ky
Functions Revisited
- Creating a Function
- Passing Arguments
- Returning Values
Summary
Chapter 12 Exploring
Game Concept
- Game Structure
- Prompting for Options
- Processing Options
- Create a Work Folder
Game Time
Test It
Summary
Chapter 13 Cleanup Time
Optimizing Your Code
- String Externalization
- Creating the Strings File
- Using Externalized Strings
Summary
Chapter 14 Reduce, Reuse, Recycle, Refactor
Understanding Refactoring
- Identifying Refactoring Opportunities
Creating a User Choice Component
- Designing a Reusable Component
- Creating the User Options Function
- Updating Your Code
Summary
Chapter 15 Carrying (and Using) Stuff
Planning the Inventory System
- Creating a Dictionary
- Working with Dictionaries
- Lists of Dictionaries
The Inventory System
- Creating an Inventory
- Plugging In the Inventory System
- Using the Inventory System
- Displaying the Inventory
Summary
Chapter 16 Keeping It Classy
The Player System
Creating a Player Class
- Creating the Class
- Defining Properties
- Creating Methods
- Initializing the Class
Using Our New Class
Summary
Chapter 17 Color Your World
Installing Third-Party Libraries
Using Colorama
- Importing and Initializing the Library
- Coloring Your Output
Summary
Chapter 18 Keep Going
- Health and Lives
- Shopping for Items
- Random Events
- Battling Enemies
- Saving and Restoring
Summary
PART III: RACING AROUND
Chapter 19 Crazy Driver
Introducing Pygame
Prepping the Game
- Game Concept
- Installing Pygame
- Creating Work Folders
- Obtaining Images
Getting Started
- Initializing Pygame
- Displaying Stuff
The Game Loop
Summary
Chapter 20 Image-ine the Possibilities
- Files and Folders
- Setting the Background
- Placing the Cars
Summary
Chapter 21 We Like to Move It
- Moving the Enemy
- Moving the Player
Summary
Chapter 22 Crash, Bang, Boom
- You Crashed, Game Over
- Tracking Score
- Increasing Difficulty
Summary
Chapter 23 Finishing Touches
- Game Over Revisited
- Pause
- Varying Enemies
- Ice Cubes
Summary
Chapter 24 Keep Going
- Splash Screen
- Scores and High Scores
- Oil Slick
- Multiple Enemies
- And Then
Summary
What Next?
There’s a Lot More to Python
- Web Development
- Mobile App Development
- Game Development
- And Then Index
Bonus Online Chapter 25 Tinkering, Testing, and Debugging Revisited (Online Only)