A good tip: use the debugger. It makes it easy to see what happens for each line. Also, try to organize your code. Do one thing at the time. You start the movement of the ball by checking the bool
collision, and only afterwards you evaluate what
collision actually needs to be. And then you again move your ball.
You'll need the laws of physics to make your ball behave correctly. Here is the correct formula you need to use:
where
x is the new position,
a is the acceleration,
v0 is the starting speed,
x0 is the starting position and
t is the total time elapsed. This is a 1D function, only focusing on 1 axis. Mind that if you want to use
sf::Sprite::move you'll need to adapt this function.
You can also make use of the derivative of the function giving you the current speed:
If you need further guidance in physics, just ask. Please do give a minimal working example instead of your complete code: remove every line that is not part of the problem: window creation, event handlers, etc. And ask specific and clear questions. The more specific and clear your questions, the more likely someone will answer them and give you what you need.