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 (GameState.Avatar.Position.Y > this.Baseline)
- {
- if (GameState.Avatar.JumpTime == 0)
- {
- GameState.Avatar.JumpHeight = GameState.Avatar.Position.Y;
- }
- GameState.Avatar.JumpTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
- if (gravitationalConstant * GameState.Avatar.JumpTime < terminalVelocity)
- {
- GameState.Avatar.Position.Y = (float)(GameState.Avatar.JumpHeight - (gravitationalConstant * Math.Pow(GameState.Avatar.JumpTime, 2)) / 2);
- }
- else
- {
- GameState.Avatar.Position.Y = GameState.Avatar.JumpHeight - terminalVelocity * GameState.Avatar.JumpTime;
- }
- } else {
- GameState.Avatar.JumpTime = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement