private void GameThread() { while (isRun) { bool f = CountFrameRate; if (f) { sw.Start(); } OnUpdate(); OnDraw(); if (ShowFPS) { Debug.WriteLine("GGG"); DrawText(0, 0, "FPS:" + (1 / elapsed), 1); } if (f) { elapsed = (float)sw.Elapsed.TotalSeconds; sw.Stop(); sw.Reset(); } } ConsoleListiner.Stop(); ConsoleListiner.KeyEvent -= OnKey; ConsoleListiner.MouseEvent -= OnMouse; }
public void StartLoop() { isRun = true; Thread = new Thread(GameThread); Thread.Priority = ThreadPriority.Highest; sw = new Stopwatch(); ConsoleListiner.Start(); ConsoleListiner.KeyEvent += OnKey; ConsoleListiner.MouseEvent += OnMouse; OnStart(); Thread.Start(); }