Asteroids

A from-scratch remake of the 1979 Atari arcade classic Asteroids, built in vanilla JavaScript on top of p5.js. No game engine, no build step — just a <canvas>, some trigonometry, and a lot of exploding rocks.

Play it now — runs entirely in the browser, nothing to install.

Asteroids gameplay preview

Features

Controls

Key Action
W Thrust forward
A Rotate left
D Rotate right
Space Fire laser
M Drop a mine (bomb)

⚠️ Firing at an armed bomb doesn’t defuse it — it makes it bigger, and angrier.

Running locally

The game is static and dependency-free (p5.js is vendored under src/libraries/), so any local web server works, for example in Python:

cd src
python3 -m http.server 8000

Then open http://localhost:8000 in your browser, or just run the convenience script: src/script.sh.

Project structure

File / dir Purpose
index.html Entry point, wires up p5.js + game scripts
sketch.js p5.js setup/draw loop, game state, collisions between sub-systems
world.js Per-frame update & render orchestration
ship.js Player ship: movement, lasers, mines
asteroid.js Asteroid spawning, movement & breakup
mine.js Bomb entity: arming, chain-reaction blast radius
laser.js Projectile entity
dust.js Explosion particle effect
hud.js Score & lives display
input.js Keyboard event dispatcher
audio/ Sound effects

(all under src/)