I think this is more of a Win32 related question than a game question. This is a simple solution for now in my game loop. It checks for collision. Here, I have two objects on the screen (PC and NPC). If they collide from (x1,y1) up to (x2,y2), a message should appear in the console saying that the collection was found. The member variables (x1,y1,x2,y2) are floats and they are casted to LONG since that is what RECT expects. It's not the fastest solution, but I just want to see that it works. Apparently, nothing is being outputed to the console. They are first initialized with a 64x64 tile, and the PC and NPC is first started off with coordinates -32, 32, 32, -32 (x1,y1,x2,y2). The grid I am using is a cartesian grid with origin in the middle of the screen (0,0). So, these tiles are 32 all around the origin. So if they start off with the same coordinates, how come there isn't any collision message?
Code:
void GetCollision(void)
{
RECT rPC;
rPC.left = (LONG) PC.x1;
rPC.top = (LONG) PC.y1;
rPC.right = (LONG) PC.x2;
rPC.bottom = (LONG) PC.y2;
RECT rNPC;
rNPC.left = (LONG) NPC.x1;
rNPC.top = (LONG) NPC.y1;
rNPC.right = (LONG) NPC.x2;
rNPC.bottom = (LONG) NPC.y2;
RECT rect;
if (IntersectRect(&rect, &rPC, &rNPC))
std::cout << "Got it." << std::endl;
}