Пример #1
0
        protected override void Update(GameTime gameTime)
        {
            if (this.IsActive)
            {
                if (_wasInactive)
                {
                    _inputHandler.InitiateInput();
                }
                _wasInactive = false;
                _inputHandler.HandleInput(_playerCommandQueue);
            }
            else
            {
                _wasInactive = true;
            }

            while (_playerCommandQueue.Count > 0)
            {
                _playerCommandQueue.Dequeue().Execute(_playerOne, (float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            if (_playerOne.HasFullscreen() != _graphicsDeviceManager.IsFullScreen)
            {
                _graphicsDeviceManager.ToggleFullScreen();
                _graphicsDeviceManager.ApplyChanges();
            }

            if (_playerOne.HasQuit() || Keyboard.GetState().IsKeyDown(Keys.Escape) || GamePad.GetState(0).IsButtonDown(Buttons.Start))
            {
                Exit();
            }
            base.Update(gameTime);
        }