Guest User

Untitled

a guest
Dec 7th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. TimeScaling::TimeScaling(float targetFPS)
  2. {
  3. this->targetFPS = targetFPS;
  4. QueryPerformanceCounter(&lastFrame);
  5. QueryPerformanceFrequency(&ticksPerSecond);
  6. }
  7.  
  8. float TimeScaling::getTimeScale()
  9. {
  10. QueryPerformanceCounter(&currentTicks);
  11. float timeScale = (float)(currentTicks.QuadPart-lastFrame.QuadPart)/((float)ticksPerSecond.QuadPart/targetFPS);
  12. if (timeScale <= 0.0d)
  13. timeScale = 1.0d;
  14. lastFrame = currentTicks;
  15. return timeScale; // Multiply this by all your movement and you're good.
  16.  
  17. }
Add Comment
Please, Sign In to add comment