Pong Paddle ball collision [rect to rect]

Started by
0 comments, last by ItsDan 16 years, 9 months ago
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.
Advertisement
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.
-----------------------------------------------“The best, most affordable way to save the most lives and improve overall health is to increase the number of trained local, primary healthcare workers.”Learn how you can help at www.ghets.org

This topic is closed to new replies.

Advertisement