Pages

PyGame Tutorials - Intro to Game Dev

Here is a small collection of tutorials we have put together to help the new game developer get their feet wet. They assume a basic understanding of the languages involved, but you can probably pick it up if you carefully follow along and search constructs you aren’t familiar with. The tutorials should be taken as a series, but if you want more advanced topics you can skip ahead as they are labeled with the major topics they highlight.

NOTE: Outdated Tutorials

These pygame tutorials were written in 2010 and are almost certainly imperfect and out of date. They are posted here for legacy reasons - hopefully they remain useful, but take everything you learn here with a grain of salt!



01 - The Plan


The goal of these tutorials is to give you a solid place to start as you get your feet wet by progressing you through the creation of a few simple well known games, slowly increasing the complexity and introducing more topics as we go.

02 - The Basics


In this tutorial we will just be getting pygame up and running. Our goal is a small template that produces a blank window that doesn’t hang that we can close with the window X or by pressing escape. Additionally we want to put our frames per second in the title bar, just for good measure.

03 - Pong - Step 1


In this tutorial we will subclass the pygame sprite class to make our paddles and ball, then control them using the keyboard. At the end we will have two paddles that move and a ball that does absolutely nothing.

03 - Pong - Step 2


In this tutorial we are going to take what we created in step 1 and add the ball, paddle/wall collisions, and scoring. At the end you’ll have a rough but playable version of pong.

03 - Pong - Step 3


In this tutorial we are going to take our pong game from step 2 and finish it up by adding ball spin and some sounds. At the end you’ll have a fully working Pong clone.

04 - Breakout - Step 1


In this tutorial we will build on what we learned in the pong tutorial. Step 1, as usual, is to just get things set up. We will create our game class and most of our sprite classes, as well as set up a default ‘level’ and place blocks in it. When we are finished we will have a screen with some blocks and a paddle at the bottom that can move.

04 - Breakout - Step 2


In this tutorial we are going to take our basic setup from step 1 and add the crux of the gameplay: collisions. At the end we should be able to serve the ball and have it bounce around, taking out blocks and rebounding as expected from the paddle, the walls, and the blocks.

04 - Breakout - Step 3


In step 2 we created a semi-playable version of breakout; we could break the blocks but there was only one level and no way to win or lose. Next tutorial we will add the rest of the gameplay, but in this one we are going to make a level editor so we can create levels very quickly and easily. At the end you should be able to crank out new levels in a couple second each.

04 - Breakout - Step 4


In this tutorial we are going to take our pong game from step 2 and finish it up by adding ball spin and some sounds. At the end you’ll have a fully working Pong clone.

04 - Breakout - Step 5 - Part 1


Now we are going to add two last features to really finish it off: powerups and a persistent high score table.

04 - Breakout - Step 5 - Part 2


Now we are going to finish step 5 by adding a high score table. This requires us to hack up a lot of our existing code so you may want to use a diff program to look at the changes between step 5 and step 4 so you can tell what is actually going on.