Okay, and what would I do with the returned value? I did my own guess and the monsters do hit me except for ones going through the center of my ship. Why would that be?
Code:
// Player colliding into the monsters
for (register int i = 0; i < MAX_MONSTERS; i++) {
if (monster[i].getAlive()) {
float val = GetDistanceSq(monster[i]);
if (val < 64)
PC.setY(900);
}
}
}
float GetDistanceSq(Monster &m)
{
float diffx = PC.getX() - m.getX();
float diffy = PC.getY() - m.getY();
return (diffx*diffx + diffy*diffy);
}
EDIT: I changed 64 to 128 and I'm getting much better and accurate results. Thanks for the help once again.