BUILD NOTES / ENGINEERING
No physics library. Every bounce is resolved by hand so the ball keeps a constant speed magnitude, never tunnels, and never lodges inside a brick.
Simulation runs at a locked 1/60s step (accumulator + guard against spiral of death), split into
2 substeps. Movement per test is ≈1.7px, far below the 20px brick height — no tunnelling on fast phones.
Circle vs box uses clamped-point overlap. The axis with the smaller penetration is the one actually crossed,
so dx flips on flanks and dy on faces. The loop breaks on the first hit and ejects the ball
by the penetration depth — a brick can never be hit twice, and velocity magnitude is preserved by renormalising after every bounce.
Contact offset rel = (ball.x − paddleCentre) / 30 maps to ±64°, so edges give shallow ricochets and the
centre gives near-vertical returns. A floor on |dy| kills degenerate horizontal loops, and paddle velocity
adds english before the vector is renormalised to the target speed.
Launch vector (2, −2.8) ≈ 3.44px/frame ramps to 3.95 across the 32 bricks —
inside the 3–4px window, so difficulty rises without breaking the tuning budget.
Brick rows, ball glow and paddle are pre-rendered to offscreen sprites once; particles and score pops are pooled caps; device pixel ratio is clamped to 2; the context is opaque. Steady 60 FPS on mid-range mobile.
Pointer, touch drag (touch-action:none, preventDefault) and keyboard all feed one smoothed
paddle target, clamped to 0…340. Canvas coords are derived from getBoundingClientRect() so the
scaled CSS size never desyncs the hit test.