Note: The metrics calculator object is called "timer" in this code.
// Loop until the program is over while (!programOver) { // Record the starting time of the loop timer.recordStartTime(); // Update the screen data screenManager.advance(); // Draw the updated screen screenManager.render(MHDisplayModeChooser.getGraphics2D()); // Record the ending time of the loop timer.recordEndTime(); // Calculate how long it took to run this loop and // use that value to see how long we should wait // (or "sleep") before starting the next iteration timer.sleep(); // Separate UPS from FPS to maintain a better frame rate. while (timer.shouldUpdate()) screenManager.advance(); } // while (!programOver) . . .
No comments:
Post a Comment