Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Collision detection (breakout)

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

It kind of depends how you're detecting your collisions...

Going for a generic method of detection, once a collision with a block has been detected, compare the position of the ball before movement with the same block. That is, if the ball hits a certain block, and was completely below the block, but not to either side of it, then it hit the block from below - a vertical collision. There is a tricky case where the ball might have hit it in the lower-left corner, and it is hard to tell whether it is vertical or horizontal - if the ball moves small distances each update, you may be able to get away with classing this as a 'corner hit', and reversing direction both vertical and horizontal.

At the other end of the generic spectrum, all of the blocks, your ball and paddle are described with polygons (or simpler rectangles for the blocks). Using polygon intersection routines, you can determine which side of the block was hit, and that will easily give you the angle of collision - this method is extendible in that you can have collisions with blocks on an angle at some later stage, but incurs extra overhead storing the polygon information.

There may be a hybrid method of detecting the collisions, using an offshoot of the a tile-based engine, and simply 'assuming' a polygon where your block array says there exists a block. This would be the most efficient method at a glance, as you could inherently discard all collisions that the ball couldn't possibly be hitting.

Umm, hope this helps... if you're doing something different than the above to detect your collisions in the first place it may not, though.

White Fire

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hello everyboy!

I'm doing (yet another) breakout, and I'm
having a bit of trouble with the collision.

I want to be able to tell the difference
between a horizontal collision and a vertical
collision. can anyone help here?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yeah, that sounds about right. I'll go with
the easy one and leave it at that.

Share this post


Link to post
Share on other sites
Hello, I am making a breakout too, in opengl. I have a collision detection working , but it isn''t perfect yet. Fell free to e-mail me to exchange informations, I would appreciate.

See ya
rah@emux.net

Share this post


Link to post
Share on other sites

  • 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!