Example #1
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            Reload();

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.F12))
            {
                _shouldReload = true;
            }

            if (_shouldReload && Keyboard.GetState().IsKeyUp(Keys.F12))
            {
                _shouldReload = false;
                _logger.LogDebug("LoadScene");
                _gee?.LoadScene();
            }

            var dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            updateTimer.Restart();

            _services.Tick(dt);

            _gee?.Update(dt);

            updateTimer.Stop();
            _updateAvg += updateTimer;
        }
Example #2
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            var dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            renderTimer.Restart();

            if (_gee != null)
            {
                GraphicsDevice.Clear(new Color(255, 255, 255, 255));
                _gee.Draw(dt);
            }
            else
            {
                GraphicsDevice.Clear(new Color(255, 50, 50, 255));
            }

            renderTimer.Stop();
            _renderAvg += renderTimer;

            Window.Title = $"Update: {_updateAvg}, Render: {_renderAvg} {renderTimer.ElapsedMilliseconds}";
        }