BREAKOUT

Insert coin
Score 0000
Lives

Service manual · Rev 1.0

Thirty-two blocks.
One 3 px ball.
No mercy.

Everything here is a single HTML file: vanilla canvas, no engine, no libraries. Physics run on a fixed 1/120 second accumulator, so a 120 Hz phone and a 60 Hz desktop resolve the exact same bounces.

  1. 01

    The grid

    8 × 4 blocks at 50 × 20, positioned by y = row*20, x = col*50. Each block is a live object with a spawn timer, so a restart rains them back in from the top.

  2. 02

    Paddle angle

    Contact offset drives the exit vector: angle = offset × 60°. Dead centre is a near-vertical return; clipping the rubber fires the ball out shallow. The magnitude never changes.

  3. 03

    Collision axis

    AABB overlap plus closest-point circle test, then the minimum translation vector decides the face — shallow horizontal overlap flips dx, shallow vertical overlap flips dy. One resolution per sub-step, so the ball can never double-bounce or tunnel through.

  4. 04

    Edge armour

    Vertical velocity is clamped out of the horizontal-lock zone, side hits on the paddle bounce the ball back into play, and hitting zero blocks ends the run on the win screen with your score.

  5. 05

    Feedback

    Brick sprites and the ball glow are pre-rendered once, particles share a pool, and the blips are raw WebAudio oscillators — no samples, no assets, no network.