Basically instead of bouncing off of the screen and to the other side it bounces between the edge and the first pixel of the edge causing it to vibrate and be stuck....
I remember of this annoying problem when I was young and started programming games :lol:
Have a look at the pong demo that comes with SFML, it has a ball that bounces on edges and paddles. Look at this excerpt:
if (ball.GetPosition().y < 0.f)
{
ballSound.Play();
ballAngle = -ballAngle;
ball.SetY(0.1f);
}
if (ball.GetPosition().y + ball.GetSize().y > window.GetView().GetSize().y)
{
ballSound.Play();
ballAngle = -ballAngle;
ball.SetY(window.GetView().GetSize().y - ball.GetSize().y - 0.1f);
}
As you see, the trick here is to move the ball a little bit back when it bounces, so that you make sure that the collision condition won't be triggered again on the next frame. If it wasn't there, the ball would change direction, but it's probably still outside of the screen so the same condition is triggered and the direction is changed indefinitely, making the annoying vibration effect.