Im currently creating a breakout clone for my first ever C# / XNA game. Currently Ive had little trouble creating the paddle object, ball object, and all the bricks. The issue im currently having is getting the ball to bounce off of the paddle and bricks correctly based off of where the ball touches the object. This is my forumala thus far:

if (paddleLocation.Intersects(ballLocation))
    position.Y = paddleLocation.Y - texture.Height;
    motion.Y *= -1;

    // determine X
    motion.X = 1 - 2 * (ballLocation.X - paddleLocation.X) / (paddleLocation.Width / 2);

The problem is, the ball goes the opposite direction then its supposed to. When the ball hits the left side of the paddle, instead of bouncing back to the left, it bounces right, and vise versa. Does anyone know what the math equation is to fix this?



ballLocation.X - paddleLocation.X


paddleLocation.X - ballLocation.X

Not the answer you're looking for? Browse other questions tagged or ask your own question.