Hello, I wrote a 2D game with some simple Collision Detection.
I used the function IntersectRect() but I think it's slow.
This is the code right now:
int Collision(CHARACTER* object1, CHARACTER* object2)
{
D3DXVECTOR3 pos1 = object1->GetPosition();
D3DXVECTOR3 pos2 = object2->GetPosition();
RECT a, b, *des;
a.left = pos1.x;
a.right = pos1.x + object1->width;
a.top = pos1.y;
a.bottom = pos1.y + object1->height;
b.left = pos2.x;
b.right = pos2.x + object2->height;
b.top = pos2.;
b.bottom = y2 + object2->height;
return IntersectRect(des, a, b);
}
Do anyone know some algorithm? D: