Exemple #1
0
    void changeState()
    {
        checkSlidingState();

        if (inputManager.getKeyDown(PlayerKeys.JUMP))
        {
            if (isGrounded)
            {
                if (fsm.validateNewAction(PlayerActions.JUMP_INPUT))
                {
                    jump(jumpSpeed, UP);
                }
            }
            else if (isOnWallUp || isOnWallDown)
            {
                if (fsm.validateNewAction(PlayerActions.JUMP_INPUT))
                {
                    float jumpDirection = isOnWallUp ? UP : DOWN;
                    float jumpSpeedWall = isOnWallUp ? jumpSpeed : jumpDownSpeed;
                    direction = (direction == RIGHT) ? LEFT : RIGHT;
                    jump(jumpSpeedWall, jumpDirection);
                }
            }
            else
            {
                doubleJump();
            }
        }
        else if (isOnWallUp && !isGrounded)
        {
            fsm.validateNewAction(PlayerActions.WALL_SLIDE);
        }

        else if (!isGrounded)
        {
            fsm.validateNewAction(PlayerActions.FALL);
        }

        else if (isGrounded)
        {
            fsm.validateNewAction(PlayerActions.RUN);
        }
    }