Making Games with Python & Pygame

When you get down to it, programming video games is just about lighting up pixels to make pretty pictures appear on the screen in response to keyboard and mouse input.

And there are very few things that are as fun.

This book will teach you how to make graphical computer games in the Python programming language using the Pygame library.

This book assumes you know a little bit about Python or programming in general. If you don’t know how to program, you can learn by downloading the free book ?Invent Your Own Computer Games with Python? from http://inventwithpython.com. Or you can jump right into this book and mostly pick it up along the way.

Table of contents

  • Who is this book for?
  • Installing Python and Pygame
  • What You Should Know Before You Begin
  • Downloading and Installing Python
  • Windows Instructions
  • Mac OS X Instructions
  • Ubuntu and Linux Instructions
  • Starting Python
  • Installing Pygame
  • How to Use This Book
  • The Featured Programs
  • Downloading Graphics and Sound Files
  • Line Numbers and Spaces
  • The QUIT Event and pygamequit() Function
  • Email questions to the author: al@inventwithpythoncom
  • Surface Objects and The Window
  • Colors
  • Transparent Colors
  • pygameColor Objects
  • pygamePixelArray Objects
  • The pygamedisplayupdate() Function
  • Animation
  • Frames Per Second and pygametimeClock Objects
  • Making the Source Code Look Pretty
  • Using Constant Variables Instead of Strings
  • Making Sure We Have Enough Icons
  • Tuples vs Lists, Immutable vs Mutable
  • One Item Tuples Need a Trailing Comma
  • Converting Between Lists and Tuples
  • The global statement, and Why Global Variables are Evil
  • Data Structures and D Lists
  • Drawing the Game State to the Screen
  • Creating the ?Revealed Boxes? Data Structure
  • Creating the Board Data Structure: Step – Get All Possible Icons
  • Step – Shuffling and Truncating the List of All Icons
  • Step – Placing the Icons on the Board
  • Splitting a List into a List of Lists
  • Different Coordinate Systems
  • Converting from Pixel Coordinates to Box Coordinates
  • Drawing the Icon, and Syntactic Sugar
  • Syntactic Sugar with Getting a Board Space’s Icon’s Shape and Color
  • Drawing the Box Cover
  • Handling the Revealing and Covering Animation
  • Revealing and Covering the Groups of Boxes
  • Slide Puzzle
  • How to Play Slide Puzzle
  • Source Code to Slide Puzzle
  • Second Verse, Same as the First
  • Setting Up the Buttons
  • Being Smart By Using Stupid Code
  • The Main Game Loop
  • Clicking on the Buttons
  • Sliding Tiles with the Mouse
  • WASD and Arrow Keys
  • Actually Performing the Tile Slide
  • IDLE and Terminating Pygame Programs
  • Checking for a Specific Event, and Posting Events to Pygame’s Event Queue
  • Creating the Board Data Structure
  • Not Tracking the Blank Position
  • Making a Move by Updating the Board Data Structure
  • When NOT to Use an Assertion
  • Getting a Not-So-Random Move
  • Converting Tile Coordinates to Pixel Coordinates
  • Drawing the Buttons
  • Animating the Tile Slides
  • The copy() Surface Method
  • Creating a New Puzzle
  • Animating the Board Reset
  • Time vs Memory Tradeoffs
  • Nobody Cares About a Few Bytes
  • How to Play Simulate
  • Source Code to Simulate
  • The Usual Starting Stuff
  • Setting Up the Buttons
  • The main() Function
  • Some Local Variables Used in This Program
  • Drawing the Board and Handling Input
  • Checking for Mouse Clicks
  • Checking for Keyboard Presses
  • The Two States of the Game Loop
  • Figuring Out if the Player Pressed the Right Buttons
  • Epoch Time
  • Drawing the Board to the Screen
  • Same Old terminate() Function
  • Reusing The Constant Variables
  • Animating the Button Flash
  • The Usual Setup Code
  • About This Book ix
  • Setting up Timing Constants for Holding Down Keys
  • More Setup Code
  • Setting Up the Piece Templates
  • Splitting a ?Line of Code? Across Multiple Lines
  • The main() Function
  • The Start of a New Game
  • The Game Loop
  • The Event Handling Loop
  • Pausing the Game
  • Using Movement Variables to Handle User Input
  • Checking if a Slide or Rotation is Valid
  • Finding the Bottom
  • Drawing Everything on the Screen
  • The calculateLevelAndFallFreq() Function
  • Email questions to the author: al@inventwithpythoncom
  • Drawing the Score and Level Text
  • Drawing a Piece on the Board or Elsewhere on the Screen
  • Keeping Track of the Location of Things in the Game World
  • Starting Off with Some Grass
  • Adding New Grass and Squirrel Objects
  • Camera Slack, and Moving the Camera View
  • Drawing the Background, Grass, Squirrels, and Health Meter
  • The Event Handling Loop
  • Moving the Player, and Accounting for Bounce
  • Collision Detection: Eat or Be Eaten
  • Reading and Writing Text Files
  • Text Files and Binary Files
  • Writing to Files
  • Reading from Files
  • About the Star Pusher Map File Format
  • Recursive Functions
  • The Flood Fill Algorithm
  • Drawing the Map
  • Checking if the Level is Finished
  • Source Code for Ink Spill
  • Source Code for Four-In-A-Row

 

Size : 4456.332 Kb
File type : pdf
Downloads: 1522
Created: 2019-05-01

Warning: Trying to access array offset on false in /home/tutovnfz/public_html/article.php on line 233

Others Python Tutorials

Python for Informatics: Exploring Information

Mastering Python

Learning to Program Using Python

A Whirlwind Tour of Python

Python for Everybody

Others related eBooks about Making Games with Python & Pygame

Introduction to language R

This pdf tutorial is an introduction to language R, free training document under 10 pages for beginners....

Csharp Programming Tutorial

Download this C# PDF Tutorial for free, it's consisting of 5 chapters covering all the most important C# concepts. This tutorial is intended for beginner programmers, and we recommend you to go through all the chapters, to get the most out of it as possible....

A Python Book: Beginning Python, Advanced Python, and Python Exercises

Download ebook Python tutorial, Python exercices, free PDF course by Dave Kuhlman....

Ruby programming tutorial

Download free Ruby tutorial course in PDF, training file in 69 chapters and 235 pages. Free unaffiliated ebook created from Stack OverFlow contributor....

Invent Your Own Computer Games with Python

Download free course Invent Your Own Computer Games with Python, pdf file on 367 pages by Al Sweigart....

Statistics with Julia

Ccurrently many of Julia's users are hard-core developers that contribute to the language'..., download free Julia tutorial in PDF (413 pages) created by Hayden Klok ....

Artificial Neural Networks - Methodological Advances and Biomedical Applications

Artificial Neural Networks (ANN) may probably be the single most successful technology in the last two decades which has been widely used in a large variety of applications in various areas. The purpose of this book is to provide recent advances of artificial neural networks in biomedical applicat...

Android™ Notes for Professionals

The fast-growing popularity of Android smartphones and tablets creates a huge opportunities for developers. If you're an experienced developer, you can start creating robust mobile Android apps right away with this professional guide....

Exploring .NET Core

Download free course Exploring .NET Core, pdf file on 155 pages by Dustin Metzgar....

Hacking Secret Ciphers with Python

Download free course Hacking Secret Ciphers with Python, pdf file on 442 pages by Al Sweigart....