Пример #1
0
        private void UpdateInput(InputState inputState)
        {
            this.Run(inputState.X);

            this.Climb(inputState.Y, inputState.Jump);

            if (inputState.Jump)
                Jump();

            if (inputState.Fire)
                Fire();
        }
Пример #2
0
        public InputState GetInputState(PlayerIndex player)
        {
            InputState state = new InputState();

            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Left))
                state.X = -1;
            else if(keyboardState.IsKeyDown(Keys.Right))
                state.X = 1;

            if (keyboardState.IsKeyDown(Keys.Up))
                state.Y = -1;
            else if (keyboardState.IsKeyDown(Keys.Down))
                state.Y = 1;

            if (keyboardState.IsKeyDown(Keys.Space))
                state.Jump = true;

            if (keyboardState.IsKeyDown(Keys.X))
                state.Fire = true;

            return state;
        }