BREAK·OUT CABINET / VANILLA JS
400 × 600 32 BRICKS 3 LIVES

PLAYER 01 · CANVAS 2D

BREAKOUT

READY

Drag anywhere on the screen to slide the paddle · Tap / Space to serve

UNDER THE
GLASS

No physics engine, no sprites, no libraries. Every pixel above is painted by the Canvas 2D API on a fixed 60 Hz simulation fed by requestAnimationFrame.

01 — COLLISION MODEL

Closest hit wins, sides and crowns behave differently

Each candidate brick is tested as a circle-vs-rect overlap against a radius-expanded AABB. The penetration depths ox and oy decide the exit axis, and the ball is pushed flush against the brick face so it can never lodge inside a neighbour.

02 — VELOCITY BUDGET

Constant magnitude, rising curve

Launch vector (2, -2.8) normalised, then scaled to 3.4 px/frame and ramped to 3.9 as the wall thins. Direction changes never add energy.

3.43.9

03 — FIELD MAP

Eight across, four deep

Brick geometry is pure arithmetic: x = col × 50, y = 64 + row × 20.

0,01,02,03,04,05,06,07,0

04 — MOBILE PIPELINE

Built for thumbs and 120 Hz screens

Non-passive touchstart / touchmove / touchend handlers kill page scroll, finger coordinates are remapped through getBoundingClientRect() into 400×600 logical space, and the buffer is scaled by devicePixelRatio (capped at 2). A fixed-timestep accumulator keeps the sim at exactly 60 ticks per second whether the display runs at 60, 90 or 120 Hz — portrait or landscape, 320 px wide and up.