making collision in pong

okay i am making pong for uni for my first assigment and i cant get my collision
to work properly and as a result my ball wont bounce of my paddles...

here its the code for the collision.


//ball impact values below
//makes ball go bouncy bouncy
if (ballx < lefpaddle_2y && ballx > lefpaddle_2y && bally > lefpaddle_2y - 20 && bally < lefpaddle_2y + 120)
ballxspeed *= -1;


if (ballx + 40 > rightpaddle_1y && ballx + 40 < rightpaddle_1y && bally > rightpaddle_1y - 20 && bally < rightpaddle_1y + 120)
ballxspeed *= -1;

ballx < lefpaddle_2y && ballx > lefpaddle_2y

How can ballx be both greater than and smaller than lefpaddle_2y?

And shouldn't it be lefpaddle_2x as well.

Same with the rightpaddle part.
trying a differant approach than that last method i found alot of problems in it like the one you pointed out to me.

so now i gunna define the top right corner of the paddle and its hight and width..if the ball comes with in those boundaires it should impacted and bounce
Topic archived. No new replies allowed.