A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Breakout - clever hit detection needed (muuaah)!

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    3
    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:





  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    106

    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

  3. #3
    Junior Member
    Join Date
    Jul 2002
    Posts
    3
    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?

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    106

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center