Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class CollisionCalculator
- {
- public static bool RadiusRadius(CollisionRadiusGO first, CollisionRadiusGO second)
- {
- double x = first.Position.X - second.Position.X;
- double y = first.Position.Y + first.HitRadiusOffset - second.Position.Y + second.HitRadiusOffset;
- double length = x + y;
- return (Math.Pow(first.HitRadius + second.HitRadius, 2) > length);
- }
- public static bool RectangleRadius(CollisionRectGO first, CollisionRadiusGO second)
- {
- float deltaX = second.Position.X - MathHelper.Max(first.Hitbox.Left, MathHelper.Max(second.Position.X, first.Hitbox.Right));
- float deltaY = second.Position.Y + second.HitRadiusOffset - MathHelper.Max(first.Hitbox.Top, MathHelper.Max(second.Position.Y + second.HitRadiusOffset, first.Hitbox.Bottom));
- return (deltaX * deltaX + deltaY * deltaY) < Math.Pow(second.HitRadius * second.HitRadius, 2);
- }
- private static bool RectangleRectangle(CollisionRectGO first, CollisionRectGO second)
- {
- return first.Hitbox.Intersects(second.Hitbox);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement