Exemplo n.º 1
0
 /// <summary>
 /// Detects collision between two BoundingRectangles
 /// </summary>
 /// <param name="a">The first BoundingRectangle</param>
 /// <param name="b">The second BoundingRectangle</param>
 /// <returns>True for collision, false otherwise</returns>
 public static bool Collides(BoundingRectangle a, BoundingRectangle b)
 {
     return(!(a.Right < b.Left || a.Left > b.Right ||
              a.Top > b.Bottom || a.Bottom < b.Top
              ));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Detects collision between a rectangle and a circle
 /// </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) => Collides(c, r);
Exemplo n.º 3
0
 /// <summary>
 /// Tests for a collision between this and a BoundingRectangle
 /// </summary>
 /// <param name="other">The BoundingRectangle</param>
 /// <returns>True for collision, false otherwise</returns>
 public bool CollidesWith(BoundingRectangle other)
 {
     return(CollisionHelper.Collides(this, other));
 }