Пример #1
0
 public static Vec2 GetUnitVectorDegrees(float degrees)
 {
     Vec2 vectorDegrees = new Vec2();
     vectorDegrees.x = Mathf.Cos(degrees);
     vectorDegrees.y = Mathf.Sin(degrees);
     return vectorDegrees;
 }
Пример #2
0
		public LineSegment (Vec2 pStart, Vec2 pEnd, uint pColor = 0xffffffff, uint pLineWidth = 1, bool pGlobalCoords = false)
		{
			start = pStart;
			end = pEnd;
			color = pColor;
			lineWidth = pLineWidth;
			useGlobalCoords = pGlobalCoords;
		}
Пример #3
0
		public Arrow (Vec2 pStartPoint, Vec2 pVector, float pScale, uint pColor = 0xffffffff, uint pLineWidth = 1)
		{
			_startPoint = pStartPoint;
			_vector = pVector;
			scale = pScale;

			color = pColor;
			lineWidth = pLineWidth;
		}
Пример #4
0
        public Player(Vec2 pPosition = null)
            : base("colors.png")
        {
            SetOrigin(width / 2, height / 2);
            position = pPosition;
            velocity = Vec2.zero;
            acceleration = Vec2.zero;

            x = position.x;
            y = position.y;
        }
Пример #5
0
		protected override void RenderSelf (GXPEngine.Core.GLContext glContext)
		{
			if (_startPoint == null || _vector == null)
				return;

			Vec2 endPoint = _startPoint.Clone().Add (_vector.Clone().Scale (scale));
			LineSegment.RenderLine (_startPoint, endPoint, color, lineWidth, true);

			Vec2 smallVec = endPoint.Clone().Sub(_startPoint).Normalize ().Scale (-10);
			Vec2 left = new Vec2 (-smallVec.y, smallVec.x);
			Vec2 right = new Vec2 (smallVec.y, -smallVec.x);
			left.Add (smallVec).Add (endPoint);
			right.Add (smallVec).Add (endPoint);

			LineSegment.RenderLine (endPoint, left, color, lineWidth, true);
			LineSegment.RenderLine (endPoint, right, color, lineWidth, true);
		}
Пример #6
0
 public Vec2 Substract(Vec2 other)
 {
     x -= other.x;
     y -= other.y;
     return this;
 }
Пример #7
0
 public Vec2 SetXY(Vec2 other)
 {
     x = other.x;
     y = other.y;
     return this;
 }
Пример #8
0
 public Vec2 RotateAroundRadians(float radians, Vec2 p)
 {
     x -= p.x;
     y -= p.y;
     RotateRadians(radians);
     x += p.x;
     y += p.y;
     return this;
 }
Пример #9
0
        public float Dot(Vec2 other)
        {
            float dot = x * other.x + y * other.y;

            return(dot);
        }
Пример #10
0
        public Vec2 Clone()
        {
            Vec2 clone = new Vec2(x, y);

            return(clone);
        }
Пример #11
0
 public Vec2 Clone()
 {
     Vec2 clone = new Vec2(x, y);
     return clone;
 }
Пример #12
0
 public Vec2 Reflect(Vec2 pNormal, float pBounciness = 1)
 {
     Sub(pNormal.Scale((1 + pBounciness) * Dot(pNormal)));
     return this;
 }
Пример #13
0
 public float Dot(Vec2 vec)
 {
     float dot = x * vec.x + y * vec.y;
     return dot;
 }
Пример #14
0
 public Vec2 Normal()
 {
     Vec2 unitNormal = new Vec2(-y, x);
     unitNormal.Normalize();
     return unitNormal;
 }
Пример #15
0
 public Vec2 RotateAroundRadians(Vec2 rotatingAround, float radians)
 {
     x -= rotatingAround.x;
     y -= rotatingAround.y;
     float positionX;
     float positionY;
     positionX = x * Mathf.Cos(radians) - y * Mathf.Sin(radians);
     positionY = x * Mathf.Sin(radians) + y * Mathf.Cos(radians);
     x = positionX + rotatingAround.x;
     y = positionY + rotatingAround.y;
     return this;
 }
Пример #16
0
 public Vec2 SetXY(Vec2 other)
 {
     x = other.x;
     y = other.y;
     return(this);
 }
Пример #17
0
 public static Vec2 GetUnitVectorDegrees(float degrees)
 {
     Vec2 vec2 = new Vec2(Mathf.Cos(Deg2Rad(degrees)), Mathf.Sin(Deg2Rad(degrees)));
     return vec2;
 }
Пример #18
0
 public Vec2 Add(Vec2 other)
 {
     x += other.x;
     y += other.y;
     return(this);
 }
Пример #19
0
 public Vec2 Add(Vec2 other)
 {
     x += other.x;
     y += other.y;
     return this;
 }
Пример #20
0
		public NLineSegment (Vec2 pStart, Vec2 pEnd, uint pColor = 0xffffffff, uint pLineWidth = 1, bool pGlobalCoords = false)
			: base (pStart, pEnd, pColor, pLineWidth, pGlobalCoords)
		{
			_normal = new Arrow (null, null, 40, 0xfffff000, 1);
			AddChild (_normal);
		}
Пример #21
0
 public float Dot(Vec2 other)
 {
     float dot = x * other.x + y * other.y;
     return dot;
 }
Пример #22
0
 public Vec2 Subtract(Vec2 other)
 {
     x -= other.x;
     y -= other.y;
     return(this);
 }
Пример #23
0
		static public void RenderLine (Vec2 pStart, Vec2 pEnd, uint pColor = 0xffffffff, uint pLineWidth = 1, bool pGlobalCoords = false) {
			RenderLine (pStart.x, pStart.y, pEnd.x, pEnd.y, pColor, pLineWidth, pGlobalCoords);
		}
Пример #24
0
 public static Vec2 GetUnitVectorRadians(float radians)
 {
     Vec2 vectorRadians = new Vec2();
     return vectorRadians;
 }
Пример #25
0
 public Vec2 Reflect(Vec2 pNormal, float pBounciness = 1)
 {
     pNormal = Normal();
     x = this.x -((1 + pBounciness) * (Dot(pNormal) * pNormal.x));
     y = this.y -((1 + pBounciness) * (Dot(pNormal) * pNormal.y));
     return this;
 }
Пример #26
0
 public Vec2 RotateAroundDegrees(float degrees, Vec2 p)
 {
     x -= p.x;
     y -= p.y;
     RotateDegrees(degrees);
     x += p.x;
     y += p.y;
     return this;
 }
Пример #27
0
 void Update()
 {
     _armVector = new Vec2(Input.mouseX - _player.x, Input.mouseY - _player.y).Normalize().Multiply(this.height * 1.5f);
     RotateArm();
 }
Пример #28
0
        public static Vec2 GetUnitVectorDegrees(float degrees)
        {
            Vec2 vec2 = new Vec2(Mathf.Cos(Deg2Rad(degrees)), Mathf.Sin(Deg2Rad(degrees)));

            return(vec2);
        }