# Breakout - clever hit detection needed (muuaah)!

• 07-09-2002, 06:39 AM
MarbleMike
Hi folks, I got stuck with my little breakout game. The problem is the ball/brick hit detection. It should detect WHAT part of the brick has been hit (corner, side, top or bottom) -while the ball speed, brick size and ball size are still variable. My head's already burning so I wonder if somebody could help me out. I had a look at some open source breakout games but I had to realize that they also had the same problem!

Here's an image illustrating my problem:

http://www.amoremio.de/images/problem.gif

• 07-09-2002, 06:47 AM
gnana
i hope this helps U
hi Mike,

I can suggest you 2 solutions for this.

First you can have seperate MC on the brick for side, corner,....and detect which MC is hitting using HitTest.

Second is as you do the controlling of the entire game, you can keep storing the angle of the brick and the ball is seperate variables, as there is a hit you can check up with this variable(angle) which will give U the part got HIT.

I Hope you could solve using it.....

best of luck
gnana
• 07-09-2002, 08:27 AM
MarbleMike
Thanks gnana,
I already tried the first method but it isn't very efficient since some of my levels will contain thirty bricks (or more).

What about the second method? Could you give me some more details about it?
• 07-10-2002, 12:26 AM
gnana
its this way
hi mike,

The first method can still be used even if you use 30000 bricks as they all are instances of 1 single brick....any how forget it.

coming to the second method....the angle of the brick if it is straight is 0 if it is cross it could be 45 or 135....like wise you can store the angle of each brick....and perform normal hit test without bothering the area of HIT.

As an instance is HIT just chk the angle of it...which will give you the position of the brick.....that solves your problem......isn't

good luck
gnana