bool CollisionRect(float ax1, float ay1, float ax2, float ay2,
float bx1, float by1, float bx2, float by2)
{
// Test for no overlap.
if (ax1 > bx2)
return false;
if (ax2 < bx1)
return false;
if (ay1 > by2)
return false;
if (ay2 < by1)
return false;
return true;
}
bool Entity::CollisionCheck(Entity *otherEntity)
{
if (CollisionRect(GetPosition().x, GetPosition().y, GetPosition().x + GetSize().x, GetPosition().y + GetSize().y,
otherEntity->GetPosition().x, otherEntity->GetPosition().y, otherEntity->GetPosition().x + otherEntity->GetSize().x,
otherEntity->GetPosition().y + otherEntity->GetSize().y))
{
return true;
}
else
return false;
}