60 FPS · 2 substeps
8×4 grid · 400×600 field · fixed 60 Hz integration
// deepest-overlap axis decides the response const oL = ball.x + r - b.x, // vs brick left oR = b.x + b.w - (ball.x - r), // vs brick right oT = ball.y + r - b.y, oB = b.y + b.h - (ball.y - r); const hz = Math.min(oL, oR), vt = Math.min(oT, oB); if (hz < vt) { // horizontal ball.x += (oL < oR ? -hz : hz) + Math.sign(dx)*0.6; ball.dx = (oL < oR ? -1 : 1) * Math.abs(dx); } else { // vertical ball.y += (oT < oB ? -vt : vt) + Math.sign(dy)*0.6; ball.dy = (oT < oB ? -1 : 1) * Math.abs(dy); } normalise(); // magnitude back to speed, |dy| ≥ 0.35