Advertisement Jump to content
Sign in to follow this  

pong and collision detection

This topic is 4674 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!