Results 1 to 3 of 3

Thread: 2D Collision Detection, HELP!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    2D Collision Detection, HELP!

    Hi, can anyone help me? How can I do 2d collision detection when I only have the x and y coords of my objects.

    Thanks.

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    To do rectangular collision, you'd need to have the height and width of the objects too.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221

    Well...

    You could also hard-code the size of your objects, and use the X and Y as a centerpoint.

    VB Code:
    1. Const ObjectSize = 32
    2.  
    3. Dim ObjectRect as RECT, ObjectX as Long, ObjectY as Long
    4.  
    5. ObjectRect.Left = ObjectX - (ObjectSize \ 2)
    6. ObjectRect.Right = ObjectX + (ObjectSize \ 2)
    7. ObjectRect.Top = ObjectY - (ObjectSize \ 2)
    8. ObjectRect.Bottom = ObjectY + (ObjectSize \ 2)

    Hope this helps...
    "1 4m 4 1337 #4xz0r!'
    Janus

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