Pong Paddle ball collision [rect to rect]
I've looked on google to see how to get the collision test for the paddle and ball, but I couldn't find anything that helped me, and I tried to think what exactly I have to test but whenever I tried to test that the ball just went right through the paddle =(
Can someone tell me what x,y,w,h values i would be testing? its a rect to rect test, C++ language SDL api. I got the ball to bounce off teh walls and to reset and register as a point if it hits the side, but I can't get the collision for the ball and rect to work.
Thanks.
My simple check involves seeing if:
box1's X is > box2's x+width
box1's x+width < box2's X
Repeated for as many axes as you need. In this case I'm not really checking for collision, I'm checking for a non-collision (ie, if either of those statements above is true, the boxes can't be colliding). If none of the conditions are true, then boxes are colliding.
box1's X is > box2's x+width
box1's x+width < box2's X
Repeated for as many axes as you need. In this case I'm not really checking for collision, I'm checking for a non-collision (ie, if either of those statements above is true, the boxes can't be colliding). If none of the conditions are true, then boxes are colliding.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement