First of all sorry about the double post. In my pong game I need to of course have the paddle reflect the ball. My ball moves by having its velocity in both the x and y axis added onto its current position.
In this piece of code I am trying to test:Code:if (pongBall.xpos<=ppaddlex+5 && pongBall.ypos-5>=ppaddley-40 && pongBall.ypos-5<=ppaddley){ pongBall.vely=pongBall.vely*-1; };
1st: if the x cordinate of pong ball = the front part of the paddle.
2nd: If the middle of the pong ball is greater than the lowest part of the paddle.
3rd: If the middle of the pong ball is less than the hightest part of the paddle.
pongBall is a class with its xpos, and ypos and there accompaning velocities name vely and vel x. ppaddle x and y are the upper left corner of the paddle.
Does anyone know why this collision detection wont work. Ive been staring at it for about 2 hours and I just cant figure it out. Sorry if I didn't give enough info please tell me and I will put up more.