Snake
Grid movement, a growing tail and buffered turns.
Ten complete, original games, each in one Python file with no assets to download. Read the code, run it, change it, or play it in your browser.
Grid movement, a growing tail and buffered turns.
Paddles, rebound angles and a beatable computer opponent.
Brick grids, side-aware bounces, lives and levels.
Rotation, wall kicks, line clears and a ghost piece.
Gravity, flapping, scrolling obstacles and scoring.
Sprites, bullets, enemy waves and particle explosions.
Tiles, responsive jumping and a scrolling camera.
Shuffled pairs, mouse and keyboard play and a timer.
Random maze generation and breadth-first search.
Two-player mode and an unbeatable minimax computer.
Every game is a single file you can read from top to bottom, organised the same way: settings at the top, classes for game objects, a Game class that handles events, updates and drawing, and a short main() loop. Once you understand one, the others are easy to follow.
.py file and run it with Python after installing Pygame.All games were tested with pygame-ce 2.5.8 and pygame 2.6.1: automated tests drive the actual game code (moving, scoring, colliding, winning and losing) and run each game's real main loop. Graphics are drawn in code, so there are no image files to manage and you are free to replace them with your own art.
The game source code on this site is released under the MIT license, so you may use it in your own projects, including commercial ones. Pygame itself is licensed under the LGPL. See licenses and attribution.