daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Top