This is the second version of the Space Invaders game, a classic arcade-style shooter. In this version, I made several improvements to the previous version, including adding multiple enemies, a scoring system, game over functionality, background music, sound effects, and a nicer display of the score. The game is implemented using the pygame
library in Python.
- Python 3
- Pygame library
- Run the script, and the game window will appear.
- Use the arrow keys (left and right) to move the player's ship horizontally.
- Press the spacebar to shoot bullets.
- Defeat the enemies by hitting them with your bullets.
- Each enemy hit earns you one point.
- Avoid enemy ships coming too close to your ship, or it's game over.
- The game will display "GAME OVER" when the player loses.
- You can restart the game by running the script again.
- Left Arrow: Move left
- Right Arrow: Move right
- Spacebar: Shoot bullets
- Added multiple enemies to make the game more challenging.
- Implemented a scoring system to keep track of the player's score.
- Display the score on the screen during gameplay.
- Added a game over functionality when an enemy ship reaches a certain Y-coordinate.
- Improved the display of the score on the screen using a custom font.
- Added background music to make the game more engaging.
- Added sound effects for shooting bullets and when an enemy is hit.
The game assets (images and sounds) should be placed in a folder named "spaceinvader" in the same directory as the Python script. The assets include the following:
- Background image: "3.jpg"
- Player's ship image: "battleship.png"
- Enemy ships image: "4.png"
- Bullet image: "bullets.png"
- Game over font: "font.ttf"
- Background music: "background.wav"
- Bullet sound effect: "laser.wav"
- Enemy hit sound effect: "explosion.wav"
Make sure to have these assets available for the game to run correctly.
- The game loop continuously updates the screen and checks for player input and collisions.
- The player can move the ship left and right and fire bullets at the enemies.
- The enemy ships move left and right, and if they reach a certain Y-coordinate, the game ends.
- When the player's bullet collides with an enemy ship, the enemy disappears, and the score is increased by one point.
- The game will display the current score on the top left corner of the screen.
- The game will show "GAME OVER" on the screen if an enemy ship reaches the specified Y-coordinate, and the player can restart the game by running the script again.