Skip to content

A Simple Project which is a Space Invader game using Pygame, where players control a spaceship to shoot enemies and earn points. Key features include player and enemy movement, collision detection, and score tracking with a game-over condition.

Notifications You must be signed in to change notification settings

M1rai76/PyGame_Rocket_Shooter

Repository files navigation

Space Invader Game 🚀

This is a simple 2D Space Invader game built using Python's Pygame library. The objective of the game is to shoot down enemies and score as high as possible before they reach the player. The game ends if any enemy reaches below a certain point on the screen.

Game Demo 🎮

Game Screenshot

Features ✨

  • Player Movement: Move left or right using the arrow keys.
  • Shooting Mechanism: Shoot bullets using the spacebar.
  • Multiple Enemies: Six enemies appear on the screen, moving side to side and advancing toward the player.
  • Score Tracking: The score is displayed on the screen, increasing with each enemy hit.
  • Game Over Screen: Displays "Game Over" when an enemy reaches below a certain point.

Setup and Installation 🛠️

  1. Clone the Repository:

    git clone https://github.com/yourusername/space-invader-game.git
    cd space-invader-game
  2. Install Dependencies:

    • Ensure that Python 3.x and Pygame are installed on your system. You can install Pygame using:
      pip install pygame
  3. Run the Game:

    python space_invader.py

Assets 🎨

  • Background Image: background.png
  • Icons and Sprites: ufo.png, player.png, enemy.png, bullet.png
  • Sounds: laser.wav, explosion.wav

Place these assets in the root directory of your project. If you need free resources, consider using royalty-free image and sound sources like OpenGameArt or Freesound.

Controls 🕹️

  • Left Arrow: Move left
  • Right Arrow: Move right
  • Spacebar: Fire bullet

Code Overview 📜

  • Player: Defined at a fixed Y position and controlled by arrow keys.
  • Enemies: Multiple enemies with randomized X and Y starting positions.
  • Bullet: Shoots from the player’s current position with a "ready" and "fire" state.
  • Collision Detection: Calculated using Euclidean distance, triggering when the bullet hits an enemy.
  • Game Over Condition: The game ends when an enemy crosses a specific Y threshold.

Functions 🔍

  • player(x, y): Draws the player on the screen at the given coordinates.
  • enemy(x, y, i): Draws the enemy at the given coordinates.
  • fire_bullet(x, y): Updates the bullet position as it fires.
  • isCollision(enemyX, enemyY, bulletX, bulletY): Detects collisions between the bullet and enemies.
  • show_score(x, y): Renders the current score on the screen.
  • game_over_text(): Displays the game-over text when the game ends.

License 📝

This project is licensed under the MIT License. Feel free to fork, modify, and use this code for personal and educational purposes.


Enjoy playing Space Invader! If you encounter any issues or have suggestions, please feel free to open an issue or pull request.

About

A Simple Project which is a Space Invader game using Pygame, where players control a spaceship to shoot enemies and earn points. Key features include player and enemy movement, collision detection, and score tracking with a game-over condition.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages