We do this at the point we're handling the vertical bounce, and we simply reduce the x-velocity by the bounciness factor as well. If we wanted to be fussy, we might have a separate bounciness factor for horizontal behaviour, perhaps related to the roughness of the surface. But for simplicity we'll use the same factor for both.
Now our tennis ball really is bouncing like a real-world ball.
We could get even fancier and add some air-resistance so it even slows down while in flight, but this is a pretty accurate simulation as it stands.
|