A confusing boolean return
Hey guys, I've been going through this book about game programming and found a collision detection function that I just can't understand how it evaluates the expression and still works correctly. I realize there's a game programming section of the boards, but I think this is more of a general C++ matter.
This is supposed to test if either of two rectangles have collided at any point. Returning true for a collision, returning false for no collision What I can't understand is, why the && operator? In my mind, for all of the expressions to be true, both rectangles would have to be literally on top of each other in all points. But, the function returns true if any part of one rectangle touches any part of the other rectangle.
BOOL Sprite::TestCollision(Sprite* pTestSprite)
RECT& rcTest = pTestSprite->GetCollision();
return m_rcCollision.left <= rcTest.right &&
rcTest.left <= m_rcCollision.right &&
m_rcCollision.top <= rcTest.bottom &&
rcTest.top <= m_rcCollision.bottom;