/// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            GameTimes.UpdateFPS(gameTime);
            if (GlobalState.ShowFPS)
            {
                _fpsLabel.SetText($"FPS: {GameTimes.FPS:0}");
            }

            SpriteDrawer.BeginDraw(_camera);
            _currentState.Draw();
            SpriteDrawer.EndDraw();

            SpriteDrawer.BeginGUIDraw();
            _currentState.DrawUI();

            if (GlobalState.ShowFPS)
            {
                _fpsLabel.Draw();
            }

            SpriteDrawer.EndGUIDraw();

            SpriteDrawer.Render();
        }
Esempio n. 2
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)
        {
            base.Update(gameTime);
            GameTimes.UpdateTimes(gameTime);
            KeyInput.Update();

            _camera.Update();

            _currentState.Update();

            if (KeyInput.JustPressedKey(Keys.F12))
            {
                GlobalState.ShowFPS = !GlobalState.ShowFPS;
            }
        }
        /// <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)
        {
            base.Update(gameTime);

            GameTimes.UpdateTimes(gameTime);
            KeyInput.Update();

            if (GlobalState.settings.pause_on_unfocus && !IsActive)
            {
                return;
            }

            _currentState.Update();

            _camera.Update();

            foreach (var effect in GlobalState.AllEffects.Where(e => e.Active()))
            {
                effect.Update();
            }

            if (KeyInput.JustPressedKey(Keys.F12))
            {
                GlobalState.ShowFPS = !GlobalState.ShowFPS;
            }

            if (GlobalState.ClosingGame)
            {
                Exit();
            }

            if (GlobalState.ResolutionDirty)
            {
                InitGraphics();
                GlobalState.ResolutionDirty = false;
            }
        }