Exemplo n.º 1
0
        private static void MainThread()
        {
            Console.WriteLine($"Main thread started. Running at {Constants.TICKS_PER_SEC} ticks per second.");
            DateTime _nextLoop = DateTime.Now;

            while (isRunning)
            {
                while (_nextLoop < DateTime.Now)
                {
                    GameLogic.Update();
                    _nextLoop = _nextLoop.AddMilliseconds(Constants.MS_PER_TICK);
                    if (_nextLoop > DateTime.Now)
                    {
                        Thread.Sleep(_nextLoop - DateTime.Now);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void MainThread()
        {
            Console.WriteLine($"Main thread has started! Running at {Constants.TICKS_PER_SECOND} ticks per second");

            DateTime nextLoop = DateTime.UtcNow;

            while (isRunning)
            {
                while (nextLoop < DateTime.UtcNow)
                {
                    GameLogic.Update();

                    nextLoop = nextLoop.AddMilliseconds(Constants.MS_PER_TICK);
                    if (nextLoop > DateTime.UtcNow)
                    {
                        Thread.Sleep(nextLoop - DateTime.UtcNow);
                    }
                }
            }
        }