Breakout

32 bricks · 3 lives · one yellow ball

engine live field 400×600 grid 8×4 fps 60
SCORE
000
LIVES
BRICKS
32
COMBO
×0
LIVE

Under the glass

implementation notes
01

Fixed-timestep integrator

Physics runs on a 16.67 ms accumulator while rendering follows requestAnimationFrame — identical feel on 60 Hz phones and 120 Hz desktops, with a 5-step catch-up cap so a background tab can never teleport the ball through a brick.

loop
02

Least-penetration AABB

Contact uses circle-vs-rect closest-point tests; the resolution axis is whichever overlap is smaller, so hitting a brick's face flips dy and hitting its flank flips dx. The ball is then pushed clear of the rect by exactly that overlap — no sticking, magnitude untouched.

collision
03

One hit per frame

Every overlapping brick is scored for penetration depth and only the closest is resolved, with a per-tick hit id guard. Corner hits therefore read as a single clean bounce instead of a jittery double-flip.

stability
04

Paddle english

Contact position maps to ±60° off the normal, plus a whisper of paddle velocity. Edge hits always send the ball up (never downward), and the side faces of the paddle reflect dx so you can cheek a shot around the wall.

control
05

Anti-stall clamp

After each brick impact the vertical component is floored, so the ball can never settle into an unwinnable horizontal ping-pong. Speed creeps from 3.6 toward 4.0 px/frame as the wall thins.

fairness
06

Input parity

Pointer and ontouchstart/move/end paths share one handler with a de-dupe window and touch-action:none, so the paddle never jumps or double-fires in portrait or landscape.

mobile