Advertisement

2D Collision Detectiong Algorithims.....

Started by September 15, 2000 03:19 PM
9 comments, last by Placenta 24 years, 3 months ago
OOPS I pressed send before I was done Sorry I''m such a Putz!!
the code could be a shorter if both the source and target width and height are the same.

bool collision(int srcX, int srcY, int srcH, int srcW, int tarX, int tarY,
int tarH, int tarW)
{
UINT xDiff,yDiff;

xDiff = abs(srcY - tarX);
yDiff = abs(srcY - tarY);

if ((xDiff < srcW)&&(xDiff < tarW))&&((yDiff{
return TRUE;
}else
{
return FALSE;
}

}







This topic is closed to new replies.

Advertisement