Results 1 to 4 of 4

Thread: Collision Detection

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    England
    Posts
    5

    Question

    Hi, if I have 2 bouncing squares, bouncing around inside a larger square how do I detect when the squares hit each other? I can get some level of detection using an IF on the top and left properties of the objects but not the whole square can anyone help? I hope this makes sense!

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    What do you mean 'some level of detection'? You will also need to check if the other sides of the squares have collided, assuming the squares can get past each other that is, but what's wrong with what you've got so far?
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Shouldn't be hard
    Code:
    a=x1t<x2t'top borders
    b=x1b>x2b'bottom borders
    c=x1l<x2l'left borders
    d=x1r>x2r'right borders
    if not((a xor b) or (c xor d) or (a xor c)) then 'collision
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    England
    Posts
    5

    Smile

    Thanks Guys!
    -------------
    F*R*A*G*O*F*F
    -------------

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