Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

pong and collision detection

This topic is 4439 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

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!

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!