예제 #1
0
        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));
        }
예제 #2
0
 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));
 }
예제 #3
0
 public static bool CollidesWith(this BoundaryRectangle r, Vector2 v)
 {
     return(v.CollidesWith(r));
 }
예제 #4
0
 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));
 }
예제 #5
0
 public static bool CollidesWith(this BoundaryRectangle r, BoundaryCircle c)
 {
     return(c.CollidesWith(r));
 }
예제 #6
0
 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);
 }
예제 #7
0
 public Platform(BoundaryRectangle br, Sprite s)
 {
     bounds    = br;
     sprite    = s;
     tileCount = (int)bounds.Width / sprite.Width;
 }