Exemplo n.º 1
0
        public override void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, Player Player, ContentManager Content)
        {
            this.UpdateTime(gameTime);
            bool CouldMoveDown = canMoveDown(gameWindow, platforms, shift);

            if (Where == WhereIGo.movingLeft)
            {
                if (canMoveLeft(gameWindow, platforms, shift))
                {
                    this.position.X -= velocity.X;
                }
                if (!Jumper.Jump(gameWindow, platforms, shift, MaxJumpHeight) && !canMoveLeft(gameWindow, platforms, shift))
                {
                    Jumper.jumpState = JumpManager.JumpState.rising;
                }
            }
            else
            {
                if (canMoveRight(gameWindow, platforms, shift))
                {
                    this.position.X += velocity.X;
                }
                if (!Jumper.Jump(gameWindow, platforms, shift, MaxJumpHeight) && !canMoveRight(gameWindow, platforms, shift))
                {
                    Jumper.jumpState = JumpManager.JumpState.rising;
                }
            }
            if (!CouldMoveDown && canMoveDown(gameWindow, platforms, shift))
            {
                Jumper.jumpState = JumpManager.JumpState.rising;
            }
        }
Exemplo n.º 2
0
 private void PlayerJump(KeyboardState oldstate, KeyboardState newState, GameWindow gameWindow, Platforms platforms, int shift)
 {
     if (!Jumper.Jump(gameWindow, platforms, shift, jumpHeight) && newState.IsKeyDown(Keys.Space) && !oldstate.IsKeyDown(Keys.Space))
     {
         jumpHeight       = 0;
         Jumper.jumpState = JumpManager.JumpState.rising;
     }
     if (newState.IsKeyDown(Keys.Space) && jumpHeight < maxJumpHeight)
     {
         jumpHeight += 20;
     }
 }