Advertisement
Guest User

Untitled

a guest
May 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1.         protected void ApplyPhysics(GameTime gameTime)
  2.         {
  3.             float gravitationalConstant = 600;
  4.             float terminalVelocity = 1000;
  5.  
  6.             if (this.Position.Y < this.Parent.Baseline)
  7.             {
  8.                 if (this._jumpTime == 0 || this.Position.Y <= this._jumpHeight)
  9.                 {
  10.                     this._jumpTime = 0;
  11.                     this._jumpHeight = this.Position.Y;
  12.                 }
  13.  
  14.                 this._jumpTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
  15.                 if (gravitationalConstant * this._jumpTime < terminalVelocity)
  16.                 {
  17.                     this.Position.Y = (float)(this._jumpHeight + (gravitationalConstant * Math.Pow(this._jumpTime, 2)) / 2);
  18.                 }
  19.                 else
  20.                 {
  21.                     this.Position.Y = this._jumpHeight + terminalVelocity * this._jumpTime;
  22.                 }
  23.             }
  24.             else
  25.             {
  26.                 this._jumpTime = 0;
  27.                 this._jumpHeight = 0;
  28.             }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement