- last_Block_Update = tickCountMicro();
- last_Second = tickCountMicro();
-
- while(is_Running)
- {
- long int time;
-
- time = tickCountMicro();
- blockUpdate();
- updateFPSCounters();
- draw();
- time = tickCountMicro() - time;
-
- rRun = (rRun * (num-1) + time) / num;
-
- //cout << "total:\t" << total << endl;
- //cout << "rR:\t" << rRun << endl;
- //total = 0;
- }
-}
-
-void blockUpdate()
-{
- long int start = tickCountMicro();
- long int diff = start - last_Block_Update;
-
- //cout << "Block" << endl;
-
- // Calculate the updates that should be run for the next draw
- update_Sum += (float)(diff * target_UPS) / 1000000;
-
- // insures the float to int cast is done once.
- int iupdate_sum = (int)update_Sum;
-
- // TODO the main run loop needs to be tested and pruned
- if (iupdate_sum > 0)
- {
- // Calculate a time step that spreads the updates out as much as
- // possible used because really quick updates are nearly wasted