Asteroid Drift Inefy interactive lab / Vector run
Game guide

Asteroid Drift

An arcade loop needs low-latency input and readable state; I built a Canvas/JavaScript Asteroids-style demo with thrust, rotation, shooting, shields, randomized spawning, collision checks, waves, scoring, and touch controls.

  • Canvas vector rendering
  • Shared keyboard/touch input
  • Wave spawning and scoring
  • Shield and cooldown systems
Status
Polished prototype / live demo
Last updated
May 2026
Back to Interactive Lab
Controls
Rotate to aim, hold thrust to build momentum, fire charged shots, and use shield only when a collision is unavoidable.
Keyboard
Arrow keys or WASD move, Space or Enter fires, Shift or S shields, P or Escape pauses, and R restarts.
Touch
Hold Left/Right to rotate, hold Thrust to move, tap Fire for shots, and hold Shield to absorb hits while energy drains.
Scoring
Small asteroids are worth points, wave clears add bonuses, later waves spawn more threats, and the best score is saved locally.
Accessibility
Score, wave, lives, shield, charge, and status text are exposed outside the canvas for nonvisual game state.
Score 0
Best 0
Wave 1
Lives 3
Shield 100%

Ready

Asteroid Drift ready.

Outer belt
Blaster
Ready
Control reference

Keyboard and touch controls

Keyboard shortcuts

  • Left / ARotate the ship left while held.
  • Right / DRotate the ship right while held.
  • Up / WHold thrust to build momentum.
  • Space / EnterFire when playing, or launch from the menu.
  • Shift / SHold the shield while energy is available.
  • P / Esc / RPause or resume with P/Esc; restart with R.

Touch controls

  • Left / RightHold to rotate the ship.
  • ThrustHold to move forward and build drift.
  • FireTap for shots when the blaster is charged.
  • ShieldHold to absorb close hits while shield energy drains.

Touch controls: hold rotation/thrust, tap Fire, hold Shield for close calls.

Scoring and progression

A focused arcade loop with readable risk and reward.

Wave pressure

Each wave starts with more large asteroids, and clearing the field advances the run instead of resetting the ship.

Scoring model

Hits award points based on asteroid size, wave clears add a bonus, and the best score persists between sessions.

Survival tools

Lives absorb mistakes, shield energy gives a short defensive window, and blaster charge prevents button-mashing from flattening the loop.

Implementation notes

Movement, shooting, collision, shield, and spawning systems.

Movement model

The ship uses rotation, thrust acceleration, drag, max-speed clamping, and screen wrapping so movement feels inertial without needing a physics library.

Shooting cadence

Bullets inherit position and direction from the ship, expire after a short lifetime, and respect a cooldown meter that is surfaced in the HUD.

Collision checks

Bullet and ship impacts use distance checks against asteroid radius, then split large rocks into smaller entities and update score, lives, particles, and wave progress.

Shield behavior

Shield input drains energy while active, recharges when released, and can absorb a crash without consuming a life if the player times it well.

Spawning rules

Asteroids spawn from screen edges with randomized heading, speed, spin, and shape points, then the wave system measures remaining asteroid work to track progress.

Input architecture

Keyboard and touch controls write into the same input state, so desktop and mobile drive one gameplay loop instead of separate code paths.

What I built

Arcade movement, wave state, and keyboard/touch combat controls.

Asteroids-style mechanics are an established genre reference; this browser implementation, visuals, and state loop are custom JavaScript.

Production readiness

Polished prototype with release hardening still ahead.

Already solid includes movement, shooting, shield state, spawning, collisions, waves, HUD feedback, best-score persistence, and keyboard/touch controls. Prototype-only areas include game balance, informal performance testing, and canvas-first accessibility. Hardening would add deterministic collision tests, difficulty tuning, mobile-device QA, performance profiling, and richer nonvisual state output.

Deployment and run notes

Static canvas game with local browser state.

Hosted/run location: GitHub Pages serves asteroid-drift.html, asteroid-drift.css, and asteroid-drift.js. Environment/config: no environment variables are required; tuning values and entity rules live in the JavaScript. External APIs/services: none beyond Canvas, Pointer Events, Fullscreen, and LocalStorage for best score. Local development: run python -m http.server 8000 and open /asteroid-drift.html. Security: no secrets or user data are sent off-device.

Keep exploring

More canvas game loops

Real-time input and collision checks are one of the lab's arcade examples; compare this demo with the other browser experiments and the main case studies for broader implementation context.