BREAKUT
canvas arcade · single file · vanilla js
400×600 8×4 GRID 3 LIVES
◀ ▶ keys · mouse · drag anywhere on mobile · tap/space to launch

UNDER THE HOOD

01

Axis resolution, not raycasts

Every brick tests as an AABB against the ball's bounding box. Overlap depth on X is compared with overlap depth on Y — the smaller penetration decides the axis, so a top hit flips dy and a side hit flips dx. The ball is pushed clear of the box on the same frame, so it can never be swallowed by a brick.

02

The paddle steers

A perpendicular reflection makes Breakout unwinnable. Instead the contact point is normalised to -1…+1 across the paddle and mapped to a ±63° exit vector. Edge contact = steep angle, centre contact = near-vertical. Vertical lock is impossible because the angle is capped.

03

One collision per frame

When the ball spans two bricks, only the nearest centre resolves; the second is handled next tick. The destroyed brick's id is locked out for a few frames, and speed is stored as a unit direction × magnitude, so a bounce never adds or bleeds energy.

04

Fixed 60 Hz timestep

Rendering follows requestAnimationFrame, physics runs on an accumulator at exactly 1000/60 ms with a 4-step catch-up cap. A 120 Hz phone gets twice the frames but the same ball speed — and a backgrounded tab doesn't teleport the ball through the wall.