Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void ApplyPhysics(GameTime gameTime)
- {
- float gravitationalConstant = 600;
- float terminalVelocity = 1000;
- if (this.Position.Y < this.Parent.Baseline)
- {
- if (this._jumpTime == 0 || this.Position.Y <= this._jumpHeight)
- {
- this._jumpTime = 0;
- this._jumpHeight = this.Position.Y;
- }
- this._jumpTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
- if (gravitationalConstant * this._jumpTime < terminalVelocity)
- {
- this.Position.Y = (float)(this._jumpHeight + (gravitationalConstant * Math.Pow(this._jumpTime, 2)) / 2);
- }
- else
- {
- this.Position.Y = this._jumpHeight + terminalVelocity * this._jumpTime;
- }
- }
- else
- {
- this._jumpTime = 0;
- this._jumpHeight = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement