コード例 #1
0
ファイル: Collisions.cs プロジェクト: papyrus42/Project3
        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
ファイル: Collisions.cs プロジェクト: papyrus42/Project3
 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
ファイル: Collisions.cs プロジェクト: papyrus42/Project3
 public static bool CollidesWith(this BoundaryRectangle r, Vector2 v)
 {
     return(v.CollidesWith(r));
 }
コード例 #4
0
ファイル: Collisions.cs プロジェクト: papyrus42/Project3
 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
ファイル: Collisions.cs プロジェクト: papyrus42/Project3
 public static bool CollidesWith(this BoundaryRectangle r, BoundaryCircle c)
 {
     return(c.CollidesWith(r));
 }
コード例 #6
0
ファイル: Player.cs プロジェクト: papyrus42/Project3
 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
ファイル: Platform.cs プロジェクト: papyrus42/Project3
 public Platform(BoundaryRectangle br, Sprite s)
 {
     bounds    = br;
     sprite    = s;
     tileCount = (int)bounds.Width / sprite.Width;
 }