I'm looking for a function that tests whether or not two rects intersect with each other. I've checked over the CRect class and it does provide an Intersect function, but the function is for something different. Is there a regular windows function that I can use? Is there one hidden somewhere in GapiDraw? If not, can we get one added to the CRect class? IntersectWith(const RECT& r) or something.
In the mean time I've made my own, so if anyone is looking for the same thing (basic collision detection, nothing fancy), here you go:
In the mean time I've made my own, so if anyone is looking for the same thing (basic collision detection, nothing fancy), here you go:
- Code:
BOOL GameUtil::RectIntersect(const CRect& r1, const CRect& r2)
{
if (r1.right < r2.left ||
r1.left > r2.right ||
r1.bottom < r2.top ||
r1.top > r2.bottom)
{
return FALSE;
}
return TRUE;
}