Cabinet 08 // brick breaker
-- FPS MODE ATTRACT BEST 000
400 × 600 · 8×4 grid

Drag anywhere on the screen · paddle follows your finger · tap to launch

Under the glass

PhysicsSpec Sheet

No engine, no libraries. Explicit axis-aligned bounding-box tests, a fixed timestep, and one collision resolved per sub-step — the way it was done when a frame cost real money.

  1. Velocity
    A fixed 60 Hz accumulator drives the sim, so the ball moves speed pixels per step on a 60 Hz phone and a 144 Hz monitor alike. Magnitude is re-normalised after every bounce — speed never drifts, only direction.
  2. Sub-stepping
    Each frame is split into 2 sub-steps. At 3.8 px/frame a ball can never tunnel a 20 px brick or skip the 10 px paddle at the corners.
  3. Block contact
    Circle-vs-AABB overlap on both axes; the shallower penetration decides the side, so a top strike flips dy and a flank strike flips dx. Only the shallowest overlap of all 32 blocks resolves per sub-step — one hit, one response, no double-flip in a corner, and the ball is pushed clear of the block it just killed.
  4. Paddle english
    rel = (ballX − centre) / 30 maps the hit point to a ±60° exit angle, biased by 5.5% of the paddle's own velocity for that frame — then re-normalised. Edges give steep deflections, the middle gives a near-vertical return.
  5. Anti-stall
    The vertical component is floored at 30% of speed after every reflection, so the ball can never lock into an infinite horizontal ping-pong between the side walls.
  6. Paddle bounds
    Clamped to x ∈ [0, 340] — the paddle cannot leave the field, and its end caps reflect the ball's horizontal velocity like a wall.
  7. Input
    Pointer drag, touch drag (touchstart / move / end, default-suppressed), mouse tracking and keyboard — each takeover cancels the last so the paddle never jitters between two masters.
  8. Lifecycle
    attract → ready → playing ⇄ paused → over | won. Attract mode plays itself with a chasing AI paddle until you put a coin in; the win/lose screens are drawn on the canvas with a live restart target.
  9. Performance
    Static field, brick rows, ball glow and paddle are pre-rendered to offscreen canvases once; the frame loop is mostly drawImage. Particle pool capped, DPR capped at 2, DOM writes only on value change.