Jump to content
  • Advertisement
Sign in to follow this  
Adir

Breakout physics

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

I'm trying to build a breakout clone using XNA. My main problem now its the ball collision detection. I know that I need to invert the ball velocity when there is a hit, but how can I know if the ball hit the left/right side of the brick or the top/bottom side? Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
Hi there. Each block is what's known as a AABB (axis aligned bounding box). There are many ways of implementing it, too, and the math isn't that difficult behind it either. Here's some more information on someone who had a similar problem:

http://board.flashkit.com/board/showthread.php?t=773872

and additionaly:

http://www.google.com/search?hl=en&rlz=1G1GGLQ_ENNZ324&q=aabb+circle+collision&aq=f&oq=&aqi=


The thing you will really need to consider when doing this though, is how you can reduce the number of rectangles you need to check against the circle otherwise you may have a performance bottle neck having something like this:


for(every rectangle)
if(collision(rectangle[n], sphere)
// bounce off


"how can I know if the ball hit the left/right side of the brick or the top/bottom side?"

You will want to store the distance from the ball's radius to the point of intersection, then should be able to calculate the normal straight off from there, then you woudln't have to worry about what side it actually hit.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!