Skip to content

WikiTeq/Pytheroids

Repository files navigation

Asteroids Game

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.

Features

1. Detailed Spaceship

  • 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.

2. Irregular Asteroids

  • 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.

3. Bullets

  • Design: Bullets are represented as small yellow circles.
  • Lifetime: Bullets have a limited lifetime, disappearing after a certain distance.

4. Particle System

  • Thruster Particles: Emitted from the spaceship's engines when accelerating.
  • Explosion Particles: Generated when asteroids are destroyed, creating a burst of debris.

5. Starfield Background

  • Design: A simple starfield is rendered in the background, enhancing the space environment.

6. Game Mechanics

  • 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.

7. Screen Wrapping

  • Mechanics: Both the spaceship and asteroids wrap around the screen edges, maintaining continuous gameplay.

Installation

  1. Python and Pygame: Ensure you have Python installed on your system. Install Pygame using pip:

    pip install pygame
  2. Run the Game: Execute the game script using Python:

    python main.py

Code Structure

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.

Future Enhancements

  • 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.

Contributing

Feel free to fork this repository and submit pull requests for any improvements or new features. Contributions are welcome!

License

This project is open-source and available under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages