コード例 #1
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public void SetLocation(Point p)
 {
     this.x = p.GetX();
     this.y = p.GetY();
 }
コード例 #2
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public int DistanceTo(Point p)
 {
     int tx = (int) (this.x - p.x);
     int ty = (int) (this.y - p.y);
     return Loon.Utils.MathUtils.Sqrt(Loon.Utils.MathUtils.Mul(tx, tx) + Loon.Utils.MathUtils.Mul(ty, ty));
 }
コード例 #3
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public void GetLocation(Point dest)
 {
     dest.SetLocation(this.x, this.y);
 }
コード例 #4
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public Point(Point p)
 {
     this.CheckPoints();
     this.SetLocation(p);
     this.type = Loon.Core.Geom.ShapeType.POINT_SHAPE;
 }
コード例 #5
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public void Set(Point.Point2i  p)
 {
     this.x = p.x;
     this.y = p.y;
 }
コード例 #6
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public int DistanceTo(Point.Point2i  p)
 {
     int tx = this.x - p.x;
     int ty = this.y - p.y;
     return Loon.Utils.MathUtils
             .Sqrt(Loon.Utils.MathUtils.Mul(tx, tx) + Loon.Utils.MathUtils.Mul(ty, ty));
 }
コード例 #7
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public int DistanceTo(Point.Point2i  p1, Point.Point2i  p2)
 {
     int tx = p2.x - p1.x;
     int ty = p2.y - p1.y;
     int u = Loon.Utils.MathUtils.Div(
             Loon.Utils.MathUtils.Mul(x - p1.x, tx) + Loon.Utils.MathUtils.Mul(y - p1.y, ty),
             Loon.Utils.MathUtils.Mul(tx, tx) + Loon.Utils.MathUtils.Mul(ty, ty));
     int ix = p1.x + Loon.Utils.MathUtils.Mul(u, tx);
     int iy = p1.y + Loon.Utils.MathUtils.Mul(u, ty);
     int dx = ix - x;
     int dy = iy - y;
     return Loon.Utils.MathUtils
             .Sqrt(Loon.Utils.MathUtils.Mul(dx, dx) + Loon.Utils.MathUtils.Mul(dy, dy));
 }
コード例 #8
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public void Untranslate(Point p)
 {
     this.x -= p.x;
     this.y -= p.y;
 }
コード例 #9
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public Point2i(Point.Point2i  p)
 {
     this.x = p.x;
     this.y = p.y;
 }
コード例 #10
0
ファイル: Point.cs プロジェクト: keppelcao/LGame
		public Point(Point p) {
			this.CheckPoints();
			this.SetLocation(p);
			this.type = ShapeType.POINT_SHAPE;
		}
コード例 #11
0
ファイル: Point.cs プロジェクト: hellogithubtesting/LGame
 public void Translate(Point p)
 {
     this.x += p.x;
     this.y += p.y;
 }
コード例 #12
0
ファイル: CollisionMask.cs プロジェクト: 207h2Flogintvg/LGame
		public static Polygon MakePolygon(int[] pixels, int offsetX, int offsetY,
				int startX, int startY, int limitX, int limitY, int interval) {
			Polygon split = null;
			Polygon result = null;
			List<Point[]> points = new List<Point[]>();
			Point[] tmpPoint;
			int x1, y1, x2, y2;
			bool secondPoint;
			int pixel = 0;
			for (int y = startY; y < limitY - interval; y += interval) {
	
				secondPoint = false;
				x1 = y1 = -1;
				x2 = y2 = -1;
				for (int x = startX; x < limitX; x++) {
					pixel = pixels[x + limitX * y];
					if (!secondPoint) {
                        if ((pixel & LSystem.TRANSPARENT) == LSystem.TRANSPARENT)
                        {
							x1 = x;
							y1 = y;
							secondPoint = true;
						}
					} else {
                        if ((pixel & LSystem.TRANSPARENT) == LSystem.TRANSPARENT)
                        {
							x2 = x;
							y2 = y;
						}
					}
				}
				if (secondPoint && (x2 > -1) && (y2 > -1)) {
					tmpPoint = new Point[2];
					tmpPoint[0] = new Point(offsetX + x1, offsetY + y1);
					tmpPoint[1] = new Point(offsetX + x2, offsetY + y2);
					CollectionUtils.Add(points,tmpPoint);
				}
			}
			split = MakePolygon(points);
			if (split != null) {
				points = new List<Point[]>();
				for (int x_0 = startX; x_0 < limitX - interval; x_0 += interval) {
					secondPoint = false;
					x1 = y1 = -1;
					x2 = y2 = -1;
					for (int y_1 = startY; y_1 < limitY; y_1++) {
						pixel = pixels[x_0 + limitX * y_1];
						if (!secondPoint) {
							if ((pixel & LSystem.TRANSPARENT) == LSystem.TRANSPARENT) {
								x1 = x_0;
								y1 = y_1;
								secondPoint = true;
							}
						} else {
							if ((pixel & LSystem.TRANSPARENT) == LSystem.TRANSPARENT) {
								x2 = x_0;
								y2 = y_1;
							}
						}
					}
					if (secondPoint && (x2 > -1) && (y2 > -1)) {
						tmpPoint = new Point[2];
						tmpPoint[0] = new Point(offsetX + x1, offsetY + y1);
						tmpPoint[1] = new Point(offsetX + x2, offsetY + y2);
                        CollectionUtils.Add(points, tmpPoint);
					}
				}
				result = MakePolygon(points);
	
			}
			return result;
		}
コード例 #13
0
ファイル: Line.cs プロジェクト: hellogithubtesting/LGame
 public float PtSegDistSq(Point pt)
 {
     return PtSegDistSq(GetX1(), GetY1(), GetX2(), GetY2(), pt.GetX(),
             pt.GetY());
 }
コード例 #14
0
ファイル: Line.cs プロジェクト: hellogithubtesting/LGame
 public float PtLineDist(Point pt)
 {
     return PtLineDist(GetX1(), GetY1(), GetX2(), GetY2(), pt.GetX(),
             pt.GetY());
 }
コード例 #15
0
ファイル: Line.cs プロジェクト: hellogithubtesting/LGame
 public Line(Point p1, Point p2)
     : this(p1.x, p1.y, p2.x, p2.y)
 {
 }
コード例 #16
0
ファイル: Point.cs プロジェクト: keppelcao/LGame
		public Point(Point p) {
			this.CheckPoints();
			this.SetLocation(p);
		}