public static bool CollidesWith(this BoundaryCircle c, BoundaryRectangle 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)); }
public static bool CollidesWith(this BoundaryRectangle a, BoundaryRectangle b) { return(!(a.X > a.X + b.Width || a.X + a.Width < b.X || a.Y > b.Y + b.Height || a.Y + a.Height < b.Y)); }
public static bool CollidesWith(this BoundaryRectangle r, Vector2 v) { return(v.CollidesWith(r)); }
public static bool CollidesWith(this Vector2 v, BoundaryRectangle r) { return((r.X <= v.X && v.X <= r.X + r.Width) && (r.Y <= v.Y && v.Y <= r.Y + r.Height)); }
public static bool CollidesWith(this BoundaryRectangle r, BoundaryCircle c) { return(c.CollidesWith(r)); }
public Player(IEnumerable <Sprite> frames, Game1 g) { this.frames = frames.ToArray(); game = g; bounds = new BoundaryRectangle(Position - 1.8f * origin, this.frames[0].Width, this.frames[0].Height); }
public Platform(BoundaryRectangle br, Sprite s) { bounds = br; sprite = s; tileCount = (int)bounds.Width / sprite.Width; }