A fully playable Asteroids clone built with Python and Pygame. Ships shoot, asteroids split, and the game ends when one catches you.
| Key | Action |
|---|---|
W |
Thrust forward |
S |
Thrust backward |
A / D |
Rotate left / right |
Space |
Shoot |
Hit an asteroid to split it into two smaller, faster ones. Asteroids below minimum size are destroyed outright. Get hit by any asteroid and it's game over.
The project uses pygame's sprite system as its backbone. Every object in the game — player, asteroids, and shots — extends a shared CircleShape base class that handles position, velocity, and circle-based collision detection.
Key pieces:
circle_shape.py— base class withcollides_with()using distance vs. combined radiusplayer.py— reads keyboard input each frame, handles rotation, movement, shooting, and a shoot cooldown timerasteroid.py— moves each frame and splits into two smaller asteroids on hit, each inheriting velocity rotated ±20–50° and scaled up by 1.2xasteroid_field.py— spawns asteroids at a set rate from random edges of the screenshot.py— projectile fired from the player's position in the direction they're facinglogger.py— writes game state snapshots and events (splits, shots, hits) to.jsonlfiles for the first 16 seconds of each run
uv sync
uv run main.py- Python 3.12
- Pygame 2.6.1