Asteroids is a classic arcade-style game where you pilot a spaceship and try not to get obliterated by floating space rocks. The game includes real-time movement, asteroid generation, collision detection, and a game loop that just won’t quit until you do.
- Player-controlled spaceship with smooth rotation (thrust-based movement coming soon)
- Randomly spawning asteroids that float in space and try to ruin your ship
- Simple collision logic for destroying your ship
- Python - the programming language for non-programmers
- Pygame - 2D game development library for Python
asteroid.py- class definition and render logic for asteroidsasteroidfield.py- collision-detection and spawn logiccircleshape.py- abstract class for circle shapeconstants.py- global constants for game environmentmain.py- main driver code with game loopplayer.py- class definition and logic for spaceshipshot.py- class definition for spaceship bullets
- Python 3.10+ installed
- Access to a unix-like shell (e.g. zsh or bash)
-
Navigate to the project directory and create a virtual environment at the top level:
python3 -m venv venv
-
Activate the virtual environment:
source venv/bin/activateYou should now see
(venv)at the beginning of your terminal prompt. -
Install the requirements:
pip3 install -r requirements.txt
-
Run the game with:
python3 main.py
-
Enjoy :)
I am not good at this :(
