예제 #1
0
bool8_t Collidable::IsColliding(Collidable other) {
	bool right = other.GetPosition().x > GetPosition().x + GetWidth();
	bool left = other.GetPosition().x + other.GetWidth() < GetPosition().x;
	bool up = other.GetPosition().y + other.GetHeight() < GetPosition().y;
	bool down = other.GetPosition().y > GetPosition().y + GetHeight();

	return right || left || up || down;
}
static bool beamCheckCollision( QVector pos, float len, const Collidable &un )
{
    return (un.GetPosition()-pos).MagnitudeSquared() <= len*len+2*len*un.radius+un.radius*un.radius;
}