Beispiel #1
0
 public static Vec2 GetUnitVectorDegrees(float degrees)
 {
     Vec2 vectorDegrees = new Vec2();
     vectorDegrees.x = Mathf.Cos(degrees);
     vectorDegrees.y = Mathf.Sin(degrees);
     return vectorDegrees;
 }
Beispiel #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;
		}
Beispiel #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;
		}
Beispiel #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;
        }
Beispiel #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);
		}
Beispiel #6
0
 public Vec2 Substract(Vec2 other)
 {
     x -= other.x;
     y -= other.y;
     return this;
 }
Beispiel #7
0
 public Vec2 SetXY(Vec2 other)
 {
     x = other.x;
     y = other.y;
     return this;
 }
Beispiel #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;
 }
Beispiel #9
0
        public float Dot(Vec2 other)
        {
            float dot = x * other.x + y * other.y;

            return(dot);
        }
Beispiel #10
0
        public Vec2 Clone()
        {
            Vec2 clone = new Vec2(x, y);

            return(clone);
        }
Beispiel #11
0
 public Vec2 Clone()
 {
     Vec2 clone = new Vec2(x, y);
     return clone;
 }
Beispiel #12
0
 public Vec2 Reflect(Vec2 pNormal, float pBounciness = 1)
 {
     Sub(pNormal.Scale((1 + pBounciness) * Dot(pNormal)));
     return this;
 }
Beispiel #13
0
 public float Dot(Vec2 vec)
 {
     float dot = x * vec.x + y * vec.y;
     return dot;
 }
Beispiel #14
0
 public Vec2 Normal()
 {
     Vec2 unitNormal = new Vec2(-y, x);
     unitNormal.Normalize();
     return unitNormal;
 }
Beispiel #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;
 }
Beispiel #16
0
 public Vec2 SetXY(Vec2 other)
 {
     x = other.x;
     y = other.y;
     return(this);
 }
Beispiel #17
0
 public static Vec2 GetUnitVectorDegrees(float degrees)
 {
     Vec2 vec2 = new Vec2(Mathf.Cos(Deg2Rad(degrees)), Mathf.Sin(Deg2Rad(degrees)));
     return vec2;
 }
Beispiel #18
0
 public Vec2 Add(Vec2 other)
 {
     x += other.x;
     y += other.y;
     return(this);
 }
Beispiel #19
0
 public Vec2 Add(Vec2 other)
 {
     x += other.x;
     y += other.y;
     return this;
 }
Beispiel #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);
		}
Beispiel #21
0
 public float Dot(Vec2 other)
 {
     float dot = x * other.x + y * other.y;
     return dot;
 }
Beispiel #22
0
 public Vec2 Subtract(Vec2 other)
 {
     x -= other.x;
     y -= other.y;
     return(this);
 }
Beispiel #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);
		}
Beispiel #24
0
 public static Vec2 GetUnitVectorRadians(float radians)
 {
     Vec2 vectorRadians = new Vec2();
     return vectorRadians;
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #27
0
 void Update()
 {
     _armVector = new Vec2(Input.mouseX - _player.x, Input.mouseY - _player.y).Normalize().Multiply(this.height * 1.5f);
     RotateArm();
 }
Beispiel #28
0
        public static Vec2 GetUnitVectorDegrees(float degrees)
        {
            Vec2 vec2 = new Vec2(Mathf.Cos(Deg2Rad(degrees)), Mathf.Sin(Deg2Rad(degrees)));

            return(vec2);
        }