A single-file arcade Space Invaders clone built with HTML5 Canvas and the Web Audio API.
| Key | Action |
|---|---|
Arrow Left / Arrow Right |
Move ship |
Space |
Fire missile |
R |
Restart (after game over) |
- 5 × 11 invader formation — 55 aliens arranged in rows, each row colour-coded (green, yellow, red).
- Endless waves — clearing all aliens advances to the next wave; speed increases each level.
- Player lives — 3 lives; lose one each time an invader bullet hits the ship.
- Scoring — 10 points per alien kill; bonus points for hitting the mystery UFO.
- Animated pixel-art sprites — two-frame marching animation toggled on every step.
- Discrete step-based movement — the formation marches in timed steps that speed up each level, then drops down and reverses direction when an edge is reached.
- Invader fire — a random alien fires downward at each movement step (1.5 % chance per step).
- Barrier erosion — any invader body that overlaps a bunker cell destroys that cell on contact, eating barriers away layer by layer as the formation descends.
- Pixel-art sprite with cockpit accent and animated engine flame.
- Shoot cooldown — a brief cooldown between shots prevents holding Space for unlimited fire.
- 4 bunkers positioned between the player and the invaders.
- Each bunker is made of individual 4 × 4 cells, each with 3 hit points.
- Visual degradation: cells turn from bright green → yellow-green → orange as they take damage.
- Destroyed cell by cell by both invader bullets and player bullets, and by direct alien contact.
- Spawns occasionally from either side of the screen and flies across the top.
- Worth 100 bonus points when shot.
- Reappears after a random cooldown.
- Shoot — short square-wave blip.
- Enemy destroyed — bright three-tone descending chime (sine + triangle layers) with a noise burst impact.
- Player death — explosion sound.
- Game over — descending triangle-wave fanfare.
- Looping chiptune melody composed of two 8-note phrases.
- Layered square-wave lead, octave-down bass, triangle harmony, and pulse sub-bass.
- Tempo scales up with each level.
- Music fades out automatically on game over.
- Pure black background with a white canvas border.
- HUD displays Lives, Level, and Score.
- Wave-clear overlay message between waves.
- Particle explosion effect on player death.
- UFO rendered with a layered pixel-art saucer shape.
- Single HTML file — all game code, styles, and assets are self-contained in
index.html. - Canvas 2D API — all rendering via
requestAnimationFrame. - Web Audio API — all sound synthesised procedurally; audio context initialised lazily on first key press to satisfy browser autoplay policy.
- AABB collision detection used for all bullet/entity interactions.
