I am making a Pong clone and I am treating my variables in this way:
direction = a value from 0 to 2*pi
distX = cos(direction)*speed of the ball
distY = sin(direction)*speed of the ball
on update:
ball's x position += distX
ball's y position += distY
I can already handle the flipping of directions correctly when a ball hits a wall (just reflect at 90 degrees) but what about a paddle? I don't know how to best handle the angle and speed of the ball after it connects.
Does it depend on where it hits on the paddle? Does it matter if the paddle is moving? etc
I don't know a reasonable way to handle the math here.
There's no "right" way of doing this. You're the one who's writing the code, and unless you've got some strict specifications, you can handle it how you prefer much.
Basically, you can handle the ball-paddle collision the same way you handle a ball-wall collision, i.e. by simply calculating the reflection angle, and assigning it to direction
.
If you want to increase the reflection angle proportionally with the paddle speed, you can simply apply some kind of weight to the new direction
.
But it's really up to you.
Anyway, if you provide, for example, the code where you handle the paddle speed, someone could give you further indication.