Walls
Circle–edge test at x±3 and y±3. The axis component flips, the other is untouched, and the ball is snapped flush to the wall so it can't buzz inside the border.
Explicit AABB · one resolution per frame
Circle–edge test at x±3 and y±3. The axis component flips, the other is untouched, and the ball is snapped flush to the wall so it can't buzz inside the border.
Offset from centre, normalised to ±1, maps to an exit angle of up to ±60°. Edge hits skid sideways, dead centre returns vertical. Paddle motion adds a touch of english.
Every overlap is scanned; the closest brick wins and the rest wait for the next frame. The deeper penetration axis decides whether dx or dy flips, then the ball is pushed clear of the cell.
Below y = 600 costs a life. Ball respawns centred on the paddle at (200, 570) with a fresh launch angle. Three misses and the run is over — 320 is the ceiling.