Model BRK-400 · 8×4 grid · 32 targets · 3 lives
BREAKOUT
HI-SCORE000
CRT 400×600 · 60Hz CH 03
SYSTEM READY COIN MECH: FREEPLAY

UNDER THE HOOD

Fixed timestep · Explicit AABB · Min-penetration resolution

01

ONE COLLISION PER FRAME

Every live brick is tested against the ball's axis-aligned box, but only the deepest overlap is resolved. The ball is ejected along that axis and the brick is cleared, so it can never be re-hit on the same tick or leave the brick grid with a corrupted velocity.

const ox = (BW/2 + R) - Math.abs(ball.x - brickCx); const oy = (BH/2 + R) - Math.abs(ball.y - brickCy); if (ox > 0 && oy > 0 && Math.min(ox, oy) < bestDepth) best = brick;
02

THE PADDLE IS A STEERING WHEEL

Vertical bounces are never perpendicular. The contact offset from the paddle centre maps to a launch angle of up to 58°, then the velocity vector is renormalised so the ball keeps a constant magnitude between 3.2 and 4.0 px/frame as bricks are cleared.

const rel = (ball.x - padCenter) / (PAD_W / 2); // -1 .. 1 const ang = rel * 1.02; ball.vx = speed * Math.sin(ang); ball.vy = -speed * Math.cos(ang);
03

NO SLOPE-LOCK, NO TUNNELLING

The vertical component is clamped so a shallow graze can't degenerate into a flat, endless horizontal bounce. Physics runs on a 1/60 accumulator with a five-step catch-up cap, so a background-tab stall never teleports the ball through the paddle on a 120 Hz phone.

04

POINTER SPACE, NOT PIXEL SPACE

The canvas backing store is scaled by devicePixelRatio while the CSS box flexes from 320px phones to desktop. Every touch is converted through getBoundingClientRect() into the fixed 400×600 simulation space, and the paddle target is lerped for smooth tracking.

const rect = cv.getBoundingClientRect(); const simX = (clientX - rect.left) * (W / rect.width);

HARD SPEC

Canvas
400 × 600
Grid
8 × 4 = 32
Brick
50 × 20
Paddle
60 × 10 @ y580
Paddle travel
0 – 340
Ball radius
3 px
Launch angle
~54° ± 9°
Speed range
3.20 – 4.00
Brick value
+10
Max score
320
Lives
3
Dependencies
none