public void GameLoop()
        {
            var      stopWatch = Stopwatch.StartNew();
            TimeSpan last      = stopWatch.Elapsed;

            InitGame();
            while (_isAlive)
            {
                // update
                var currentTimeSpan = stopWatch.Elapsed;
                _phaseManager.Update(currentTimeSpan - last);

                // render game phase
                _phaseManager.Render(_backBuffer);

                // render logs (if needed)
                _logsOverlay.Render(_backBuffer);

                _backBuffer.Render();
                _backBuffer.Render(CreateGraphics());

                Application.DoEvents();

                last = currentTimeSpan;
            }

            _backBuffer.Dispose();
        }
Esempio n. 2
0
        public void GameLoop()
        {
            var      stopWatch = Stopwatch.StartNew();
            TimeSpan last      = stopWatch.Elapsed;

            using (BufferedGraphics backBuffer = InitBackBuffer())
            {
                InitGame();
                while (_isAlive)
                {
                    // update
                    var currentTimeSpan = stopWatch.Elapsed;
                    _phaseManager.Update(currentTimeSpan - last);

                    // render
                    _phaseManager.Render(backBuffer);

                    backBuffer.Render();
                    backBuffer.Render(CreateGraphics());

                    Application.DoEvents();

                    last = currentTimeSpan;
                }
            }
        }