I see where I can do intersections on surface rects, but what about just rects?
And checking to see if a point is in a rect?
And checking to see if a point is in a rect?
A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.
//Check if 2 rectangles intersect
bool RectIntersect(RECT *rc1, RECT *rc2)
{
if (rc1 == NULL || rc2 == NULL)
return(false);
if (rc1->right <= rc1->left || rc1->bottom <= rc1->top)
return(false);
if (rc2->right <= rc2->left || rc2->bottom <= rc2->top)
return(false);
if (rc1->right <= rc2->left || rc1->left >= rc2->right)
return(false);
if (rc1->bottom <= rc2->top || rc1->top >= rc2->bottom)
return(false);
return(true);
}
//Check if a point is inside the rectangle
bool InRect(RECT *rc, POINT *pnt)
{
if (rc == NULL || pnt == NULL)
return(false);
if (pnt->x >= rc->left && pnt->x < rc->right)
if (pnt->y >= rc->top && pnt->y < rc->bottom)
return(true);
return(false);
}