press and hold space or mouse to aim and release to shoot
The ball gets its velocity and splits it into its x and y components. When bouncing off a wall it goes past the wall, measures the distance it takes to reach the wall, moves that ball past the wall and inverts an x or y velocity and recalculates angle, The red line shows where the ball would go without changing angle to show it's an accurate bounce