Space Invader is a classic arcade-style game built using HTML, CSS, and JavaScript. The game challenges players to defend Earth from waves of alien invaders by controlling a spaceship and shooting down enemies. The game is designed to be fast-paced and increasingly difficult with each new wave.
- HTML: Structure of the game (Canvas for rendering)
- CSS: Styling of the game interface
- JavaScript: Game logic, animations, and user input
- requestAnimationFrame: For smooth and efficient animations
- getBoundingClientRect: Used to detect collisions between elements (spaceship, bullets, invaders)
- Spaceship movement: Move left or right with keyboard controls.
- Shooting mechanics: Shoot projectiles to destroy invaders.
- Collision detection: Detects hits between the player's bullets and the invaders using
getBoundingClientRect. - Game over condition: The game ends if the invaders reach the bottom of the screen or the player’s spaceship is hit.
- Score tracking: Player's score is displayed at the top of the screen.
- Start the game: Open the game in your web browser.
- Control the spaceship: Use the left and right arrow keys to move your spaceship.
- Shoot: Press the spacebar to fire a bullet at the invaders.
- Defeat the invaders: Shoot down as many invaders as possible to increase your score.
- Game Over: If an invader reaches the bottom of the screen or if your spaceship is hit, the game ends.
- Restart the game: Refresh the page to start a new game after losing.
-
Download the repository to your local machine or clone it using Git:
git clone https://github.com/MohcineDev/PAC.git``` -
open in vs code
code . -
open index.html in a browser
