Classic Asteroids-style arcade game implemented in Python using Pygame.
Teach myself Python after not using it since College. The language itself is very straightforward. It didn't take me long to adapt from JS and C# back to Python. I enjoyed getting to grips with this "old friend."
Requirements
- Python >= 3.12 (see .python-version)
- Pygame 2.6.1 (see pyproject.toml)
Run the game:
python main.pyThe game entrypoint is main.main.
- W / S — thrust forward / reverse
- A / D — rotate left / right
- Space — fire
- Simple physics-based movement and rotation
- Multiple asteroid sizes and splitting behaviour
- Shots with rainbow colours
- Starfield background with parallax + twinkle
- Score tracking and high score persistence
- Lightweight event/state logging for debugging
Key behaviors are implemented in:
- Player:
player.Player - Asteroid:
asteroid.Asteroid - Asteroid spawn manager:
asteroidfield.AsteroidField - Generic circle sprite base:
circleshape.CircleShape - Shots:
shots.Shots - Score persistence/UI:
score.Score - Background:
starfield.StarField - Logging helpers:
logger.log_state,logger.log_event - Constants:
constants
- .gitignore
- .python-version
- asteroid.py
- asteroidfield.py
- circleshape.py
- constants.py
- highscore.txt
- logger.py
- main.py
- player.py
- pyproject.toml
- README.md
- score.py
- shots.py
- starfield.py
- Sprite classes subclass
circleshape.CircleShapeand register themselves with pygame groups inmain.py. - Logging writes compact JSONL snapshots to game_state.jsonl and events to game_events.jsonl.
- High score is stored in highscore.txt (loaded/written by
score.Score).
Common constants are in constants.py (player speed, turn speed, spawn rate, radii).
- Fixes, improvements and bug reports via issues and pull requests.
- No other contributors.
There is no license for this repo. Feel free to play around.