The classical equation for realistic gravity is, if I remember correctly:
initial_position = 0; // where the ball is at the beginning of the jump
initial_velocity = xxx; // some positive initial velocity
gravity = 9.81; // on earth
void update()
{
time = clock.getElapsedTime().asSeconds();
velocity = -0.5 * gravity * time * time + initial_velocity;
position = velocity * time + initial_position;
// handle bouncing
if (position <= 0)
{
clock.restart();
initial_velocity = -velocity; // * factor
initial_position = position;
}
}
(probably needs some adjustments, but that's the idea)
That's for Y axis. For X axis it's easier, velocity remains constant as there's no horizontal gravity.
To make the ball bounce, you have to invert velocity when it reaches the ground, and optionally multiply it with a factor because it loses energy when it touches the ground (factor < 1).