Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Update(GameTime gameTime, KeyboardState keyboardState)
- {
- // Calculate strafe
- if (keyboardState.IsKeyDown(Keys.Left) || keyboardState.IsKeyDown(Keys.Right))
- {
- if (keyboardState.IsKeyDown(Keys.Left))
- velocity.X = -strafe_mutator;
- else
- velocity.X = strafe_mutator;
- } else
- velocity.X = 0;
- // Determine the state of the player
- if (position.Bottom >= 600)
- {
- // player is not in the air
- velocity.Y = 0;
- position.Y = 600 - position.Height;
- // check for jumping
- if (keyboardState.IsKeyDown(Keys.Space))
- velocity.Y = -jump_mutator;
- } else
- // player is in the air
- velocity.Y += (gravity_mutator) * gameTime.ElapsedGameTime.Milliseconds;
- position.X += (int)velocity.X;
- position.Y += (int)velocity.Y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement