Cabinet 01 · HTML5 Canvas · No libraries

Breakout

Thirty-two cyan bricks, three lives, one sixty-pixel paddle dragged by finger or arrow key. Everything you see below is painted by ctx.

Drag anywhere on the screen to slide the paddle Release — the paddle holds position Edges of the paddle fire the ball off-angle

Under the glass

No physics engine. A fixed 1/60 accumulator drives the simulation; rendering is decoupled, so a 120 Hz phone animates twice as smoothly without the ball moving twice as fast.

Collision model

Circle vs. axis-aligned box, resolved on the axis of least penetration:

ox = (w/2 + r) − |dx| · oy = (h/2 + r) − |dy|

  • oy ≤ ox → flip dy, eject top/bottom.
  • ox < oy → flip dx, eject left/right.
  • Only the closest brick is resolved per step; each brick remembers its last hit frame, so a ball can never re-hit the same brick twice or tunnel into it.
  • After every brick/paddle hit the velocity is re-normalised — the ball is always re-normalised, so the speed magnitude never drifts.

Paddle angle

Hit position maps to a ±60° exit angle: sin(θ)·s / −cos(θ)·s. Centre contact goes almost straight up, corners scream off sideways.

A vertical floor of 0.34·s stops the ball from grinding horizontally forever.

Touch & performance

  • Non-passive touchstart / move / end + mouse + pointer parity.
  • Rect-mapped coordinates → correct on portrait, landscape, 320 px up.
  • Bricks & ball are pre-rendered to offscreen sprites (glow baked once), then blitted — no per-frame shadowBlur storm.
  • Static field drawn once to a cached background canvas; particles capped.