Containment
The ball's bounding box is tested against every live brick and the three walls. A broad-phase reject on the brick grid keeps the loop at 32 cheap comparisons per step.
Thirty-two blocks, three lives and one sixty-pixel paddle standing between the ball and the void below. Pure canvas. No libraries.
Four explicit rules run once per fixed 1/60 s step. No physics engine, no swept solver — just tight AABB maths with penetration resolution and a single-winner pass that keeps the ball out of the brick walls.
The ball's bounding box is tested against every live brick and the three walls. A broad-phase reject on the brick grid keeps the loop at 32 cheap comparisons per step.
Penetration depth on each axis decides which face was struck. The shallower axis is the one that crossed, so the ball ejects along the correct normal — never the wrong one.
When two bricks overlap the ball's box at once, only the deepest is resolved; the second is picked up next frame. Two flips in one step would cancel out and trap the ball inside the wall.
After every bounce the velocity vector is re-normalised to constant magnitude, with minimum components that kill degenerate horizontal lock. Speed rises 3.6 → 4.0 as the wall thins.