pong game.

I am making a pong game in sdl.
So how i can check if the ball is hited in the center or in the lefft-right side so to the correct direction?
Just change the ball's x velocity based on how far from the center of the paddle it lands.

1
2
3
4
5
if(collision(Paddle,Ball))
{
Ball.vy *= -1;
Ball.vx += (Ball.x - Paddle.x) * Modifier;
}


Or, if you use the left or right side of the paddle as its position:
 
Ball.vx += (Ball.x - Paddle.x -/+ Paddle.length/2) * Modifier;
Last edited on
can add me in skype to help me?
Because i did not understand.?

my skype is hepic.hepic

add me and after delete me if you want.
Topic archived. No new replies allowed.