Exemple #1
0
 static void Pre_Update()
 {
     currentFrame = DateTime.Now;
     TimeSpan delta = currentFrame.Subtract(lastFrame);
     lastFrame = currentFrame;
     TimeSpan duration = currentFrame.Subtract(start);
     currentTurn = DateTime.Now;
     deltaTurn = currentTurn.Subtract(lastTurn);
     if (deltaTurn.TotalMilliseconds >= TimePerTurn)
     {
         lastTurn = currentTurn;
         TetrisBoard.DoTurn();
     }
     while (delta.TotalMilliseconds < (1 / FPS_CAP) * SECOND)
     {
         currentFrame = DateTime.Now;
         delta = currentFrame.Subtract(lastFrame);
     }
     firstLine = duration.Hours + ":" + duration.Minutes + ":" + duration.Seconds;
     secondLine = (1 / delta.TotalSeconds) + " FPS\t" + delta.TotalMilliseconds + " ms";
     haveARest = true;
 }