A faithful recreation of the classic Asteroids arcade game, built using Python and Pygame with a focus on clean Object-Oriented Programming (OOP) design.
In this game, you control a spaceship that can rotate, thrust, and shoot. When a large asteroid is shot, it splits into two medium asteroids; medium asteroids split into two small ones, and small asteroids disappear when shot. The game loop is driven by delta time to ensure smooth performance.
- 🚢 Player spaceship with smooth rotation, thrust, and shooting mechanics
- 🪨 Asteroids break into progressively smaller pieces (Large → Medium → Small → Destroyed)
- 💥 Collision detection between bullets and asteroids
- 🔄 Delta time-based loop for consistent gameplay across devices
- 🧱 Modular OOP design with classes like
Player,Asteroid,Shot, andCircleShape
- Python 3
- Pygame 2
- Object-Oriented Programming (OOP)
-
Clone the repository:
git clone <repo-link> cd asteroids_clone
-
Create a virtual environment(recommended)
python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate
-
Install dependencies
pip install pygame
-
Run the game
python3 main.py- Inheritance: All game entities like asteroids and the player inherit from a common
CircleShapebase class for shared behavior. - Encapsulation: Each game object manages its own state and behavior.
- Modularity: Easily extendable and maintainable due to well-separated concerns and class-based architecture.
- WASD: Move and rotate the spaceship
- Spacebar: Shoot
- ESC: Exit game
