I have a simple game consisting solely of a ball and paddle. I made it so that when the ball hits the paddle, xa = 0 and ya = Math.abs(ya) * -1. The ball goes straight up like I want it to, but it’s moving a lot slower. Does anyone know what accounts for this and how I can make up for it?
Are ‘xa’ and ‘ya’ the x and y velocities of the ball? If so, if xa
is non-zero before the bounce, the speed of the ball will always be slower after the bounce. The larger |xa|
is before the bounce, the more pronounced the difference will be.
If you want the speed to remain the same, set ya
to whatever the length of (xa, ya)
was before the bounce (+ or -, as appropriate).