Advertisement

Collision detection (breakout)

Started by August 09, 1999 08:53 PM
2 comments, last by GameDev.net 24 years, 6 months ago
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

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?

Advertisement
Yeah, that sounds about right. I'll go with
the easy one and leave it at that.
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
http://www.stas.net/rafael/icq: 11915640

This topic is closed to new replies.

Advertisement