CABINET 01 · ONLINE HTML5 CANVAS · VANILLA JS · NO LIBRARIES CREDIT 01
Brick breaker · 8 × 4 grid · 320 max

BREAKOUT

Fixed 60 Hz physics, swept AABB collision with penetration-depth resolution, and a paddle that maps contact point to bounce angle. Clear all 32 bricks before the third ball drops.

400 × 600 canvas 32 bricks · 10 pts ball 3.44 px/f touch + mouse + keys
READY
DRAG / ← →60 FPS

System Logic

How the ball, paddle and grid negotiate contact

Fixed timestep, free render

Physics accumulate in 16.67 ms slices, so a 120 Hz phone renders twice as smoothly without doubling ball speed. Rendering is decoupled and interpolated by state, never by elapsed time.

Swept movement, two sub-steps

Each 60 Hz step moves the 3 px ball in halves and tests collisions between them. That stops a fast ball from tunnelling through a 20 px brick row or a 10 px paddle.

AABB + penetration depth

The ball's bounding box is tested against every live brick; the closest overlap wins, and the axis with the smaller penetration decides the reflected component — vertical overlap flips dy, horizontal flips dx.

One collision per sub-step

After a hit the ball is pushed out along the collision normal and the brick is flagged dead before the loop breaks — no brick is consumed twice, and adjacent cells resolve on the next sub-step.

Angle map, constant magnitude

Paddle contact maps −1…1 across the 60 px face to ±60° from vertical, plus a nudge from paddle momentum. Velocity is then renormalized to 3.44 px/step, so hits never inflate or stall the speed.

✓Launch is not straight up — starts at dx 2, dy −2.8 (3.44 px/step, ~35° off vertical).
✓Edge hits are shallow — rim contact returns a near-horizontal path; a floor on |dy| keeps it recoverable.
✓No brick trapping — positional push-out plus a per-sub-step collision budget.
✓Paddle clamped 0–340 — sides and top are all live surfaces; a side graze flips dx.
✓Closest brick only — simultaneous multi-brick overlap resolves one per sub-step.
✓320 ceiling — 32 bricks × 10 points, verified against the win condition.