How to calculate direction of ball upon collision?

112 Views Asked by At

I'm creating a game (Breakout) that involves a paddle and ball. I'm having trouble calculating the direction that I should send the ball after collision with the paddle.

Currently, upon collision I've reversed the Y velocity of the ball so it gets sent upwards, but if, for example, it hits the left side of the paddle and the paddle is moving to the left, how would I know where to send the ball? I'm not sure how to calculate this.

I want the user to have more control over where the ball goes instead of just reversing the Y velocity - this just keeps the ball going in a constant square.