A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27

Thread: Baby Battle

  1. #21
    Senior Member devnull_2k's Avatar
    Join Date
    Oct 2001
    Location
    Limehouse, Ontario - Never heard of it? Not surprised.
    Posts
    785
    That's ridiculous. Totally unneeded. He's obviously not hitTesting the entire babyMCs against eachother. That's the only problem. hitTest works fine.

    The code you wrote IS hitTest!
    Last edited by devnull_2k; 04-10-2003 at 08:36 PM.
    The future belongs to those who prepare for it today.

  2. #22
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    i think he might be talkin about this;
    http://www.nlc.net.au/~oceana/games/collision3.swf
    http://www.nlc.net.au/~oceana/games/collision3.zip
    (try rotating both boxes about 45 degrees and then moving them so they are right next to each other, parallel, but not touching)
    when you rotate an mc you distort it's bounding box and therefore introduce the possibility of a hittest returning true even though the two objects arn't touching. now the getbounds method is not perfect, it's just a little more accurate.
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  3. #23
    Timetravelling Superhero AJ Infinity's Avatar
    Join Date
    Oct 2002
    Location
    The Realms of Infinity
    Posts
    203
    Originally posted by devnull_2k
    That's ridiculous. Totally unneeded. He's obviously not hitTesting the entire babyMCs against eachother. That's the only problem. hitTest works fine.

    The code you wrote IS hitTest!
    My code makes the babies exert force on each other when they hit.
    From here to infinity,
    A J I N F I N I T Y

  4. #24
    Senior Member devnull_2k's Avatar
    Join Date
    Oct 2001
    Location
    Limehouse, Ontario - Never heard of it? Not surprised.
    Posts
    785
    heh, I apologize.
    The future belongs to those who prepare for it today.

  5. #25
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    me too
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  6. #26
    Lunatic Baukereg's Avatar
    Join Date
    Nov 2000
    Location
    Lowlands
    Posts
    853
    Sorry for interupting
    This is my hitTest: otherbaby.hitTest(_x,_y,true)
    It's not perfect, but also not to complicated. The bounds idea is good, but I don't want the babies to get stuck. The shape of the babies is to complicated. And as adityadennis says, it's a side projects, so I keep it this way.

    Atleast here's an update:
    http://regnerus.port5.com/babybattle/babybattle.htm

    - Sound added
    - Other picto's for the power-ups
    - A chair added; I want more objects, to they're fighting in a livingroom or something

    I removed the sterio panning (AJ Infinity, thanx for the words ), because it influences all the sound.

  7. #27
    Timetravelling Superhero AJ Infinity's Avatar
    Join Date
    Oct 2002
    Location
    The Realms of Infinity
    Posts
    203
    My code wasn't that complicated. It didn't test the whole contour of the babies, it just checked to see if their bounding boxes were colliding and made them apply force on each other so they wouldn't walk through each other (note they stop walking through each other when their centers touch, because of hitTest(x, y, true).) I suggest multiple getBounds() methods only for people who are good with math, though. hitTest() is a simple method. Read the collision detection chapters in Physics for Game Developers and Flash MX Game Design Demystified.

    Code:
    if(baby_1.hitTest(baby_2){
       if(baby_1._y > baby_2._y){
         baby_2._y = baby_1.getBounds(_root).yMax + 2;
     } else if(baby_1._y < baby_2._y){
         baby_2._y = baby_1.getBounds(_root).yMin - 2;
     }
      if(baby_1._x > baby_2._x){
         baby_2._y = baby_1.getBounds(_root).xMax + 2;
     } else if(baby_1._x < baby_2._x){
         baby_2._y = baby_1.getBounds(_root).xMin - 2;
     }
    }
    From here to infinity,
    A J I N F I N I T Y

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