Beispiel #1
0
        public static bool CollidesWith(this BoundingCircle c, BoundingRectangle r)
        {
            var closestX = Math.Max(Math.Min(c.X, r.X + r.Width), r.X);
            var closestY = Math.Max(Math.Min(c.Y, r.Y + r.Height), r.Y);

            return(Math.Pow(c.Radius, 2) >= Math.Pow(closestX - c.X, 2) + Math.Pow(closestY - c.Y, 2));
        }
Beispiel #2
0
 public static bool CollidesWith(this BoundingCircle c, Vector2 v)
 {
     return(v.CollidesWith(c));
 }
Beispiel #3
0
 public static bool CollidesWith(this Vector2 v, BoundingCircle c)
 {
     return(Math.Pow(c.Radius, 2) >= Math.Pow(v.X - c.X, 2) + Math.Pow(v.Y - c.Y, 2));
 }
Beispiel #4
0
 public static bool CollidesWith(this BoundingRectangle r, BoundingCircle c)
 {
     return(c.CollidesWith(r));
 }
Beispiel #5
0
 public static bool CollidesWith(this BoundingCircle a, BoundingCircle b)
 {
     return(Math.Pow(a.Radius + b.Radius, 2) >= Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2));
 }