Beispiel #1
0
        private void HandleKeyboardInput()
        {
            // Move object
            Vector2 direction = Vector2.Zero;

            if (_input.IsKeyDown(Keys.W))
            {
                direction.Y--;
            }
            if (_input.IsKeyDown(Keys.A))
            {
                direction.X--;
            }
            if (_input.IsKeyDown(Keys.S))
            {
                direction.Y++;
            }
            if (_input.IsKeyDown(Keys.D))
            {
                direction.X++;
            }

            if (direction != Vector2.Zero)
            {
                Link.Move(direction);
            }

            if (_input.IsKeyReleased(Keys.W))
            {
                Link.Idle();
            }
            if (_input.IsKeyReleased(Keys.A))
            {
                Link.Idle();
            }
            if (_input.IsKeyReleased(Keys.S))
            {
                Link.Idle();
            }
            if (_input.IsKeyReleased(Keys.D))
            {
                Link.Idle();
            }

            // Attack
            if (_input.IsKeyPressed(Keys.Space))
            {
                Link.Attack();
            }
        }