Pygame Tutorial
A complete Pygame path from beginner to pro - windows, game loops, sprites, animation, platformers, polish, packaging, and real game projects.
Curriculum
Work through each section in order. Every lesson ends with practice and key points so the idea sticks.
Getting Started
- 1What is Pygame?
Learn what Pygame is, what it can build, and how it fits into Python game development.
9 min - 2Install Python and Pygame
Install Python 3, set up a virtual environment, and install Pygame or pygame-ce.
11 min - 3Your First Pygame Window
Create a window with pygame.init and display.set_mode, then quit cleanly.
10 min - 4The Game Loop
Understand the process-update-draw cycle that keeps a game alive every frame.
12 min - 5Surfaces and Colors
Learn what a Surface is, how colors work, and how the screen Surface relates to drawing.
11 min
Drawing & Display
- 6Drawing Shapes
Draw rectangles, circles, lines, and polygons with pygame.draw.
12 min - 7flip() vs update()
Learn how display.flip and display.update show your drawings on screen.
9 min - 8Rectangles and pygame.Rect
Use pygame.Rect for position, size, movement, and handy edge properties.
12 min - 9Clock and Frame Rate
Control how fast your game runs with pygame.time.Clock and tick.
10 min
Input
- 10Events and Quitting
Handle the event queue, detect QUIT, and close your game cleanly.
10 min - 11Keyboard Input
Read keydown events and use key constants like K_LEFT and K_SPACE.
11 min - 12Mouse Input
Track mouse position and respond to clicks with mouse events and mouse.get_pos.
11 min - 13Holding Keys vs Keydown
Compare KEYDOWN events with pygame.key.get_pressed for smooth held movement.
12 min
Sprites & Media
- 14Images and blit
Load an image Surface and draw it with blit at a position.
11 min - 15load, convert, convert_alpha
Speed up blits and preserve transparency with convert and convert_alpha.
10 min - 16Fonts and Text
Render score and labels with pygame.font and blit the text Surface.
11 min - 17Sound and Music Basics
Play short sound effects and background music with mixer.Sound and music.
12 min - 18Collision with Rect
Detect overlaps with colliderect and respond when two rectangles touch.
12 min - 19Keep Objects On Screen
Clamp positions so players and objects cannot leave the window bounds.
10 min
First Game
- 20Move a Player Rectangle
Build a controllable player with held keys, speed, and screen clamping.
12 min - 21Falling Objects
Spawn objects that fall downward and reset when they leave the screen.
12 min - 22Score and Lives
Track score and lives, update them on catch or miss, and draw them with a font.
12 min - 23Organize With Functions
Split a growing game into functions for setup, input, update, and draw.
13 min - 24Mini Project: Catch Game
Build a complete catch game with player, falling items, score, lives, and game over.
14 min - 25Beginner Review and Next Steps
Review beginner Pygame skills and choose practical next projects to grow.
10 min
Sprites & Groups
- 26The Sprite Class
Subclass pygame.sprite.Sprite to give game objects an image, a rect, and a clean update method.
12 min - 27Sprite Groups
Organize sprites into Group and GroupSingle containers so you can update and draw many objects at once.
12 min - 28update and draw Groups
Drive the game loop with group.update() and group.draw(screen), including custom draw order when needed.
11 min - 29Custom Events and Timers
Schedule recurring actions with pygame.USEREVENT, set_timer, and custom event types for spawning and cooldowns.
13 min - 30Removing Sprites with kill()
Remove sprites from all groups safely with kill(), and clean up bullets, enemies, and pickups when they leave play.
11 min
Animation & World
- 31Frame Animation
Cycle through a list of surfaces over time to animate idle, run, and jump frames on a sprite.
13 min - 32Sprite Sheets
Load a sprite sheet image and slice it into frames with subsurface rectangles for compact animation assets.
14 min - 33Scrolling Backgrounds
Create endless or parallax scrolling backgrounds by wrapping blit positions as the camera or player moves.
12 min - 34Camera Follow
Track the player with a camera offset so large levels can scroll while sprites stay in world coordinates.
14 min - 35Tile Maps Intro
Represent levels as grids of tile IDs, convert them into rects or sprites, and draw a tile-based world.
14 min - 36Loading Levels From Data
Load level layouts from JSON or text files so you can edit maps without changing game code.
13 min
Platformer Skills
- 37Gravity and Platforms
Apply gravity with vertical velocity and resolve landing on solid platform rects for a basic platformer body.
14 min - 38Jumping and Grounded State
Implement jumps that only start when grounded, with coyote time and jump buffering as optional feel upgrades.
13 min - 39Better Collision Responses
Improve platformer collisions with one-way platforms, head bumps, and safer ordering against multiple tiles.
15 min - 40Simple Enemy Patrol
Build enemies that walk back and forth between points or edges, flipping direction on walls and ledges.
12 min - 41Health and Damage
Track hit points, apply damage with invulnerability frames, and react when health reaches zero.
13 min - 42HUD and UI Overlays
Draw health, score, and messages in screen space above the world so the HUD stays fixed while the camera moves.
12 min
Game Flow
- 43Menus and Game States
Structure the app as menu, play, and other states so input and drawing stay organized as the project grows.
14 min - 44Pause and Game Over
Add pause overlays and game-over handling that freeze gameplay while still drawing the world underneath.
12 min - 45Constants and Config
Centralize screen size, speeds, colors, and paths in a config module so tuning does not require hunting through files.
11 min - 46Gamepad Basics
Read joysticks and controllers with pygame.joystick for movement axes and button presses alongside the keyboard.
13 min - 47Intermediate Project: Platformer
Combine sprites, camera, tiles, gravity, enemies, health, and game states into a small playable platformer.
16 min - 48Intermediate Review
Review sprites, animation, cameras, tile maps, platformer physics, combat, HUD, and game flow before advanced topics.
12 min
Architecture
- 49Object-Oriented Game Architecture
Structure a Pygame project with clear classes for the game loop, entities, and systems so features stay easy to extend.
16 min - 50Scene Manager Pattern
Switch between menu, play, pause, and game-over screens cleanly with a scene stack and lifecycle hooks.
15 min - 51Resource Manager
Cache images, sounds, and fonts so assets load once, fail clearly, and stay easy to reload during development.
14 min - 52Lightweight Entity Components
Compose game objects from small data and behavior pieces without adopting a full ECS framework.
17 min - 53Data-Driven Design
Move tuning values, spawn tables, and level layouts into data files so design changes do not require rewriting code.
15 min
Polish & Performance
- 54Particle Systems
Add juice with lightweight particle bursts for explosions, thrusters, dust, and pickups.
16 min - 55Scaled Pixel Art Display
Render to a low-resolution internal surface and scale it up for crisp pixel art on modern displays.
14 min - 56Performance Tips
Keep frame rates stable with smarter blits, fewer allocations, group collision choices, and careful surface use.
15 min - 57Profiling Your Game
Find real bottlenecks with timing probes, cProfile, and simple on-screen frame metrics.
13 min - 58Packaging and Distributing
Bundle a Pygame project into a shareable build with PyInstaller, clean assets, and a short run checklist.
16 min
Capstones & Next
- 59Capstone: Space Shooter
Build a complete vertical space shooter with scenes, spawning, collisions, score, and particle juice.
18 min - 60Capstone: Endless Runner
Create a side-scrolling endless runner with scrolling ground, obstacle spawning, jump feel, and rising difficulty.
17 min - 61Capstone: Puzzle Game
Implement a grid puzzle with board state, input selection, match rules, and cascade clears.
18 min - 62Saving Progress
Persist settings, unlocks, and high scores with JSON save files and safe load defaults.
13 min - 63Polish Checklist
Use a practical checklist for feel, feedback, clarity, accessibility basics, and release readiness.
12 min - 64Pygame vs Pygame-ce
Understand the relationship between Pygame and Pygame-ce, what to install, and how to keep projects compatible.
12 min - 65Next Steps in Game Dev
Plan what to learn after Pygame: stronger design habits, tools, engines, and a portfolio project path.
12 min