Classic arcade action.
Move fast. Shoot smart. Survive the waves.
Features โข Tech Stack โข Getting Started โข How to Play โข Screenshots
Space Blaster is a browser-based space shooter game built with HTML, CSS, and JavaScript. Players control a spaceship to defend against waves of enemies, fire lasers, survive increasingly challenging encounters, and aim for the highest possible score.
The project delivers a classic arcade-style experience while demonstrating clean game logic, DOM-based rendering, and structured JavaScript architecture.
Space Blaster includes the following core gameplay and system features:
-
Player Movement and Controls ๐ฎ
Control the spaceship using the left and right arrow keys with smooth and responsive movement. -
Laser Shooting ๐ซ
Fire lasers using the space bar to eliminate incoming enemies. -
Enemy Waves ๐พ
Enemies appear in waves, move strategically, and shoot back, increasing the challenge over time. -
Scoring System ๐
Points are awarded for each enemy destroyed. The HUD displays score, time, and remaining lives. -
Lives and Health โค๏ธ
The player starts with multiple lives. Getting hit by enemy lasers reduces lives until game over. -
Pause and Resume โธ๏ธ
Pause or resume gameplay instantly using the P key. -
Mute / Unmute Sounds ๐
Toggle sound effects and background audio using the M key. -
Game Over and Congratulations Screens ๐
Display end-game results and milestone-based congratulatory messages. -
Restart Functionality ๐
Restart the game easily after a game-over screen to attempt a higher score.
Space Blaster is built entirely with standard web technologies:
- HTML ๐ โ Structures the game layout and interface
- CSS ๐จ โ Styles the game, HUD, and screens
- JavaScript (ES6) โก โ Manages game logic, animations, and events
- DOM Manipulation ๐ผ๏ธ โ Renders and animates game elements
- Audio API ๐ โ Controls sound effects and background music
These technologies ensure compatibility and smooth performance across modern browsers.
The objective of Space Blaster is to recreate the feel of classic arcade shooters while focusing on core gameplay mechanics:
- Player ๐ค โ User-controlled spaceship
- Enemies ๐พ โ AI-controlled opponents
- Lasers ๐ซ โ Projectiles from both player and enemies
- HUD ๐ โ Displays score, time, and lives
Game state and logic are fully managed using JavaScript functions and variables.
The game operates using a continuous update loop:
Player Input โ Update Positions โ Check Collisions โ Render Frame โ Repeat
| Component | Purpose | Key Functions |
|---|---|---|
| Player | User-controlled ship | createPlayer(), updatePlayer() |
| Enemies | AI opponents | createEnemy(), updateEnemies() |
| Lasers | Projectiles | createLaser(), updateLasers() |
| HUD | Game information display | updateHUD() |
Start Game โ Move & Shoot โ Survive Waves โ Game Over โ Restart
- Players begin the game, control the ship, defeat enemies, and attempt to survive as long as possible.
- Scores increase progressively with each enemy destroyed.
- A modern web browser (Chrome, Firefox, Safari, Edge)
- No additional installations required
- Clone the repository:
git clone https://github.com/sahmedhusain/spaceblaster.git
- Navigate to the project directory:
cd spaceblaster - Open the game:
Alternatively, double-click the file.
open index.html
- Click Start to begin the game
- Move using Left / Right Arrow Keys
- Shoot using the Space Bar
- Pause / Resume using P
- Mute / Unmute audio using M
- Restart after game over
- Movement: Horizontal movement within screen boundaries
- Shooting: Unlimited lasers with cooldown control
- Enemies: Spawn from the top and move downward
- Collisions: Lasers and entities are destroyed on contact
- Uses
requestAnimationFramefor smooth 60 FPS updates - Continuously updates player, enemies, lasers, and HUD
- Listens for key presses and releases
- Prevents invalid or unintended inputs
- Tracks active, paused, and game-over states
- Maintains score, time, and lives
The init() function:
- Creates the player object
- Initializes enemy and laser arrays
- Sets initial score, lives, and time
- Loads and prepares audio assets
Executed every frame:
- Calculate delta time
- Update player position
- Update lasers
- Update enemies
- Detect collisions
- Update HUD
- Check end-game conditions
- Grid-based movement
- Random laser firing
- New wave spawns after elimination
- Player lasers travel upward
- Enemy lasers travel downward
- Rectangle overlap collision detection
- Enemy destroyed: +10 points
- Player hit: โ1 life
- Time bonus applied at game end
- Pause halts the game loop
- Mute sets all audio volume to zero
Although no database is used, this diagram represents in-game entity relationships:
cd spaceblaster
open index.htmlls -lapython3 -m http.server 8000- index.html โ Game layout
- css/main.css โ UI styling
- js/game.js โ Main game loop
- js/player.js โ Player logic
- js/enemy.js โ Enemy behavior
- js/laser.js โ Laser mechanics
- js/control.js โ Input handling
- Invalid inputs are ignored
- DOM rendering issues are logged
- Audio loading failures default to silent mode
Fork the repository, apply improvements, and submit a pull request. Please follow JavaScript best practices and test across multiple browsers.
Licensed under the MIT License. See LICENSE.md for details.
Created as part of a web game development learning experience, inspired by classic space shooter games.
- Sayed Ahmed Husain โ sayedahmed97.sad@gmail.com
- Qassim Aljaffer
- HTML5 and DOM-based game development
- JavaScript game loops and event handling
- Object-oriented programming concepts
- Audio and graphics integration
- Cross-browser compatibility
- No progressive difficulty levels
- Limited enemy variety
- Basic visuals and sound effects
- No high-score persistence
- Multiple levels with increasing difficulty
- Power-ups and special weapons
- Enhanced graphics and animations
- Online leaderboards
- Multiplayer support