The ball goes all jittery if it hits the very top or bottom of the paddles. Other than that everything works fine.
Any ideas of what I can do to eliminate the jitters or is there something in the library that I am using wrong?
Code to create the shapes:
// Shapes sf::RectangleShape paddle1; sf::RectangleShape paddle2; sf::RectangleShape ball; paddle1.setSize(sf::Vector2f(50,100)); paddle1.setPosition(20,250); paddle1.setTexture(&texPaddle); paddle2.setSize(sf::Vector2f(50,100)); paddle2.setPosition(730,250); paddle2.setTexture(&texPaddle); ball.setSize(sf::Vector2f(50,50)); ball.setPosition(400,300); ball.setTexture(&texBall);
Collision Code:
//Collision
if(ball.getGlobalBounds().intersects(paddle1.getGlobalBounds()))
{
xVelBall *= -1;
boink.play();
}
if(ball.getGlobalBounds().intersects(paddle2.getGlobalBounds()))
{
xVelBall *= -1;
boink.play();
}

New Topic/Question
Reply




MultiQuote





|