Breakut

8 × 4 grid · 320 max · 3 lives · vanilla canvas

←→ / AD or mouse  ·  Space launch  ·  P pause  ·  R restart

touch: drag anywhere on the board to slide · tap to launch or restart

02 — under the hood

Hand-rolled AABB collision with side-aware response.

  1. 01

    Which face did it hit?

    For every brick the circle test runs against the closest point on the rect, then overlap on X vs overlap on Y decides the axis: shallow X overlap → flip dx, shallow Y overlap → flip dy. Corner hits resolve on the smaller penetration, so the ball never reverses on the wrong axis.

  2. 02

    One resolution per substep

    Each frame is split into two half-steps. Inside a step, only the single nearest candidate collision is processed and the ball is pushed flush against that surface — no double flips, no brick stacks absorbing the ball, no tunnelling through a 20px row.

  3. 03

    Speed and angle are never allowed to decay

    After every bounce the velocity is renormalised to the constant magnitude and clamped between 9° and 59° off vertical. Paddle bounces derive angle from hit offset (sin/cos of up to 63°) plus a touch of paddle momentum, so edge hits skim and centre hits snap back up.

Board
400 × 600 px, device-pixel aware
Grid
8 cols × 4 rows · 50 × 20 px at row·20, col·50
Paddle
60 × 10 px at y 580 · clamp 0–340
Ball
r 3 px · served from (200, 570)
Speed
3.40 → 4.00 px/frame, magnitude locked
Scoring
+10 per brick · 320 clear