示例#1
0
        /// <summary>
        /// Determines if there is a collision between a circle and rectangle
        /// </summary>
        /// <param name="r">The bounding rectangle</param>
        /// <param name="c">The bounding circle</param>
        /// <returns>true for collision, false otherwise</returns>
        public static bool Collides(BoundingRectangle r, BoundingCircle c)
        {
            BoundingPoint p = new BoundingPoint(MathHelper.Clamp(c.X, r.X, r.X + r.Width), MathHelper.Clamp(c.Y, r.Y, r.Y + r.Height));

            return(Collides(c, p));
        }
示例#2
0
 /// <summary>
 /// Detects a collision between a rectangle and a point
 /// </summary>
 /// <param name="r">The rectangle</param>
 /// <param name="p">The point</param>
 /// <returns>true on collision, false otherwise</returns>
 public static bool Collides(BoundingRectangle r, BoundingPoint p)
 {
     return(p.X >= r.X && p.X <= r.X + r.Width && p.Y >= r.Y && p.X <= r.Y + r.Width);
 }
示例#3
0
 /// <summary>
 /// Detects a collision between a circle and point
 /// </summary>
 /// <param name="c">the circle</param>
 /// <param name="p">the point</param>
 /// <returns>true on collision, false otherwise</returns>
 public static bool Collides(BoundingCircle c, BoundingPoint p)
 {
     return(Math.Pow(c.Radius, 2) >= Math.Pow(c.X - p.X, 2) + Math.Pow(c.Y - p.Y, 2));
 }
示例#4
0
 /// <summary>
 /// Detects a collision between two points
 /// </summary>
 /// <param name="p1">the first point</param>
 /// <param name="p2">the second point</param>
 /// <returns>true when colliding, false otherwise</returns>
 public static bool Collides(BoundingPoint p1, BoundingPoint p2)
 {
     return(p1.X == p2.X && p1.Y == p2.Y);
 }
 /// <summary>
 /// Determines if this BoundingRectangle collides with a BoundingPoint
 /// </summary>
 /// <param name="p">the bounding point</param>
 /// <returns>true on collision, false otherwise</returns>
 public bool CollidesWith(BoundingPoint p)
 {
     return(CollisionHelper.Collides(this, p));
 }
 /// <summary>
 /// Determines if this BoundingPoint collides with another BoundingPoint
 /// </summary>
 /// <param name="o">the other bounding point</param>
 /// <returns>true on collision, false otherwise</returns>
 public bool CollidesWith(BoundingPoint o)
 {
     return(CollisionHelper.Collides(o, this));
 }