Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape) || exitGame)
            {
                Exit();
            }

            if (isLoading)
            {
                base.Update(gameTime);
            }
            ;

            // Switch to the next bloom settings preset?
            if (InputHelper.WasKeyPressed(Keys.B))
            {
                bloomSettingsIndex = (bloomSettingsIndex + 1) % BloomSettings.PresetSettings.Length;
                bloom.Settings     = BloomSettings.PresetSettings[bloomSettingsIndex];
            }

            if (GamePad.GetState(PlayerIndex.One).Triggers.Right > 0.00001f)
            {
                _zoom = 1.5f;
            }

            if (GamePad.GetState(PlayerIndex.One).Triggers.Left > 0.00001f)
            {
                _zoom = 1f;
            }

            cam.UpdateCameraZoom(_zoom, gameTime);
            // bloom.UpdateBloom(bloomIntensityIndex, gameTime);

            InputHelper.UpdateStates();
            GameManager.Update(gameTime);
            MusicManager.Update();

            // Just for fun - here I've added a pulse animation by adjusting the bloom saturation:

            /*BloomSatPulse += bloomSatDir;
             * if (BloomSatPulse > 2.5f) bloomSatDir = -0.09f;
             * if (BloomSatPulse < 0.1f) bloomSatDir = 0.09f;
             * bloom.Settings.BloomSaturation = BloomSatPulse;*/

            base.Update(gameTime);
        }