pong and collision detection

Started by
0 comments, last by jonahrowley 18 years ago
I am creating a pong game and need to detect the pong ball as it strikes the pong paddles
Advertisement
This is very easy. Either you ball is a circle, or it's a rect. Both rect-rect and circle-rect collision-detection is easy.

Rect-rect is extra easy since you don't have to account for rotation. First check if any of the points of either rect are inside the other rect. If they are, there's a collision. But the rects can overlap without any points being inside, so you also have to check if any of the line segments intersect. Since the line segments are all either vertical or horizontal, this is extra easy.

Even easier, since you know each paddle will be in a certain vertical position. If the ball reaches this position, check if it is also within the horizontal bounds of the current position of the paddle. This would be the overall easiest way.

Come to think of it, I don't see any reason to use circle collision detection here. That second method should be a snap to implement, maybe 4 if statements. Hope this helps!

This topic is closed to new replies.

Advertisement