# Breakout physics

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

## 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 on other sites
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:

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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 15
• 14
• 46
• 22
• ### Forum Statistics

• Total Topics
634054
• Total Posts
3015274
×