コード例 #1
0
ファイル: Speed.cs プロジェクト: 207h2Flogintvg/LGame
		public static Vector2f GetVelocity(Vector2f velocity, Vector2f force,
				float mass) {
			Vector2f acceleration = new Vector2f(force.GetX() / mass, force.GetY()
					/ mass);
			velocity.Add(acceleration);
			return velocity;
		}
コード例 #2
0
ファイル: Speed.cs プロジェクト: 207h2Flogintvg/LGame
		public static Vector2f ElasticForce(Vector2f displacement,
				float forceConstant) {
			float forceX = -forceConstant * displacement.GetX();
			float forceY = -forceConstant * displacement.GetY();
			Vector2f theForce = new Vector2f(forceX, forceY);
			return theForce;
		}
コード例 #3
0
        public void GetClosestPoint(Vector2f point, Vector2f result)
        {
            loc.Set(point);
            loc.Sub(start);

            float projDistance = vec.Dot(loc);

            projDistance /= vec.LengthSquared();

            if (projDistance < 0)
            {
                result.Set(start);
                return;
            }
            if (projDistance > 1)
            {
                result.Set(end);
                return;
            }

            result.x = start.GetX() + projDistance * vec.GetX();
            result.y = start.GetY() + projDistance * vec.GetY();
        }
コード例 #4
0
ファイル: Sprite.cs プロジェクト: 207h2Flogintvg/LGame
 public void UpdateLocation(Vector2f vector)
 {
     this.SetX(MathUtils.Round(vector.GetX()));
     this.SetY(MathUtils.Round(vector.GetY()));
 }
コード例 #5
0
 public float GetDY()
 {
     return(end.GetY() - start.GetY());
 }