Exemplo n.º 1
0
        private void RenderLoop()
        {
            var start     = DateTime.Now;
            var lastFrame = DateTime.Now;

            while (true)
            {
                var frameStart   = DateTime.Now;
                var elapsed      = frameStart - lastFrame;
                var totalElapsed = DateTime.Now - start;
                var time         = new AppTime(elapsed.TotalSeconds, totalElapsed.TotalSeconds);
                lock (stateLock)
                {
                    if (interrupt)
                    {
                        return;
                    }
                    if (!enabled)
                    {
                        continue;
                    }
                }


                Update(time);
                Draw(time);

                DrawToConsole();

                lastFrame = frameStart;

                // this should keep the CPU usage down to a minimum
                // since we dont need super fast rendering, this is fine.
                Thread.Sleep(UPDATE_INTERVAL);
            }
        }
Exemplo n.º 2
0
 protected abstract void Update(AppTime appTime);
Exemplo n.º 3
0
 protected abstract void Draw(AppTime appTime);