I have a game with some ball and I want to make it bounce. I already have movement, gravity, collisions implemented, I only need to make it bounce. Thing is, using this code:
player.getVelocity().y *= Player.ENERGY_LOSS;
player.getVelocity().y = -player.getVelocity().y;
indeed it makes the ball bounce but obviously the .y will get to very small values causing the ball to 'vibrate' and never stop.
How can I 'clamp' this value? Let's say I just want the ball to bounce just 2 - 3 times?