A clone of the classic arcade game Asteroids implemented in pure HTML5 canvas, without dependencies or bundlers.
Spaceship in an asteroid field with edge wrapping (space is toroidal). Destroy asteroids to score points: large ones split into medium ones, medium ones into small ones. Includes special power-ups and unique asteroid types like the shooting star.
- HTML5 Canvas — 2D rendering
- JavaScript (ES6+) — game logic in a single
game.jsfile - No frameworks, no bundlers, no dependencies
Open index.html directly in your browser (double-click), or use a local server:
npx serve .Then visit http://localhost:3000.
| Key | Action |
|---|---|
← → |
Rotate ship |
↑ |
Propel |
Space |
Fire |
S |
Change ship skin |
| Asteroid | Points |
|---|---|
| Large | 20 |
| Medium | 50 |
| Small | 100 |
| Shooting star | 200 |
All points are doubled while flying the Amethyst skin.
- 3 lives with temporary invincibility upon respawning (blinking)
- Asteroids break into smaller fragments upon destruction
- Explosion particles when asteroids are destroyed
- Velocity power-up: doubles ship thrust for 5 seconds. Spawns periodically on the field and can drop from destroyed asteroids; collect the cyan hexagon to activate it
- Shield power-up: protects the ship for 6 seconds. While active, a pulsing green bubble vaporizes any asteroid that touches it. Spawns periodically on the field and can drop from destroyed asteroids; collect the green hexagon to activate it
- Triple shot power-up: fires three parallel bullets for 5 seconds. Spawns periodically on the field and can drop from destroyed asteroids; collect the magenta hexagon to activate it
- Shooting star: fast golden asteroid worth 200 points that never splits. Spawns periodically with a comet tail and bursts into golden particles when its time runs out
- Ship skins: press
Sto cycle through 6 hull styles (Classic, Dart, Falcon, Phoenix, Ray, Amethyst), each with its own color scheme and thruster flame. The pick persists between sessions vialocalStorage, the life icons match the active skin, and a persistent on-screen hint plus a brief name toast show which skin is active - Amethyst skin: a purple ship twice the size of the original — bigger target, bigger hitbox — that earns double points for everything it destroys
This project is developed with OpenCode:
- Worktree command:
.opencode/commands/defines a custom command that creates a git worktree under.worktrees/<name>from a short task description (.worktreesis gitignored). Skins, shield and triple shot were built this way in parallel branches. - GitHub Actions: the repository workflow
.github/workflows/opencode.ymlruns OpenCode when the owner comments/ocor/opencodeon an issue, and OpenCode opens a pull request with the change (the Amethyst skin came from an issue this way). It requires theOPENCODE_API_KEYrepository secret. - Local setup: copy
.env.templateto.envand setOPENCODE_API_KEY..envis gitignored.