Getting started
Install Pygame and open your first window. The ten lines every game starts with.
Fifteen lessons that take you from an empty window to a scrolling platformer. Every code example is a complete program you can download and run.
Start here if you know basic Python but have never made a game. Each lesson builds on the one before.
Install Pygame and open your first window. The ten lines every game starts with.
Events, update, draw. Frame rate, delta time and smooth movement.
Rectangles, circles, lines, polygons and arcs, combined into a scene.
KEYDOWN events for single actions, get_pressed() for smooth movement.
Clicks, position, dragging and the scroll wheel in a paint program.
Load images, convert_alpha(), and organise objects with Sprite and Group.
A complete catch game with score, lives, difficulty and restart.
Animation, collisions, physics, sound and game structure, the parts that turn a demo into a game.
Sprite sheets, frame timing and animation states.
Rects, circles, masks, sprite groups and resolving overlaps.
Gravity, velocity, friction, bouncing and fixed time steps.
Sound effects, background music, volume and channels.
Title, pause and game-over screens with a state machine.
Combos, score popups and a saved high score.
Larger systems that combine everything: tile-based worlds and a full platformer.
Tiles, gravity, responsive jumps and a scrolling camera.
Grid levels, CSV loading, pre-rendering and scrolling.
The lessons are ordered: each assumes you've done the ones before it, and each ends with exercises. Doing the exercises, even badly, is where most of the learning happens. When a lesson's code works, change one number and predict what will happen before you run it again.
What you need: Python 3 with Pygame or pygame-ce installed (installation guides) and a code editor. If you can't install anything right now, the editor examples run in Pygame Online.
What you should already know: variables, if statements, for and while loops, functions and lists. Classes are introduced gently from the sprites lesson onward. If Python itself is new to you, the official Python tutorial covers everything you need in its first nine chapters.
| Concept | Where it's used |
|---|---|
| Loops and conditions | every game loop, event handling |
| Functions | drawing helpers, resetting a game |
| Lists and dictionaries | collections of enemies, game state |
| Classes and inheritance | pygame.sprite.Sprite subclasses |
| f-strings | score and debug text |
pathlib.Path | finding image and sound files |
json | saving high scores and settings |
Read the source of the game projects: each is a single, commented file. The API reference explains the modules in more depth, and the blog covers packaging, performance and publishing your game.