A modular implementation of the classic Asteroids game using Python and Pygame. This version features enhanced graphics with detailed spaceship design, particle effects, and irregular asteroid shapes.
- Design: The spaceship is designed with a complex shape, including a nose, rear, cockpit, and wings.
- Thruster Effects: When the spaceship accelerates, thruster particles are emitted, creating a realistic engine effect.
- Invulnerability: After losing a life, the spaceship becomes temporarily invulnerable, indicated by a blinking effect.
- Shapes: Asteroids are drawn as irregular polygons with varying numbers of points, giving them a more natural, rocky appearance.
- Sizes: Asteroids come in three sizes, each with different scores and behaviors when destroyed.
- Explosion Effects: When an asteroid is hit, it explodes into particles, adding a dynamic visual effect.
- Design: Bullets are represented as small yellow circles.
- Lifetime: Bullets have a limited lifetime, disappearing after a certain distance.
- Thruster Particles: Emitted from the spaceship's engines when accelerating.
- Explosion Particles: Generated when asteroids are destroyed, creating a burst of debris.
- Design: A simple starfield is rendered in the background, enhancing the space environment.
- Controls:
- Movement: Use arrow keys or WASD to rotate and thrust the spaceship.
- Shooting: Press the spacebar to fire bullets.
- Restart: Press 'R' to restart the game after a game over.
- Lives: The player starts with three lives, displayed as small ship icons.
- Score: Points are awarded for destroying asteroids, with larger asteroids yielding more points.
- Game Over: The game ends when all lives are lost, with an option to restart.
- Mechanics: Both the spaceship and asteroids wrap around the screen edges, maintaining continuous gameplay.
-
Python and Pygame: Ensure you have Python installed on your system. Install Pygame using pip:
pip install pygame
-
Run the Game: Execute the game script using Python:
python main.py
The game is organized into several modules for better maintainability:
- main.py: Entry point that initializes and runs the game
- game.py: Main game class that handles the game loop, collision detection, and rendering
- spaceship.py: Spaceship class with movement, drawing, and particle effects
- asteroid.py: Asteroid class with physics, irregular shape generation, and explosion effects
- bullet.py: Bullet class for projectile physics and rendering
- particle.py: Particle system for visual effects like thrusters and explosions
- constants.py: Game constants like colors, dimensions, etc.
- utils.py: Utility functions for text rendering, starfield creation, etc.
- Sound Effects: Add sound effects for shooting, explosions, and thrusters.
- Power-ups: Introduce power-ups for extra lives, shields, or enhanced weapons.
- Multiplayer Mode: Implement a local multiplayer mode for cooperative or competitive play.
Feel free to fork this repository and submit pull requests for any improvements or new features. Contributions are welcome!
This project is open-source and available under the MIT License.