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.
Printable View
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.
To do rectangular collision, you'd need to have the height and width of the objects too.
You could also hard-code the size of your objects, and use the X and Y as a centerpoint.
VB Code:
Const ObjectSize = 32 Dim ObjectRect as RECT, ObjectX as Long, ObjectY as Long ObjectRect.Left = ObjectX - (ObjectSize \ 2) ObjectRect.Right = ObjectX + (ObjectSize \ 2) ObjectRect.Top = ObjectY - (ObjectSize \ 2) ObjectRect.Bottom = ObjectY + (ObjectSize \ 2)
Hope this helps...