Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TimeScaling::TimeScaling(float targetFPS)
- {
- this->targetFPS = targetFPS;
- QueryPerformanceCounter(&lastFrame);
- QueryPerformanceFrequency(&ticksPerSecond);
- }
- float TimeScaling::getTimeScale()
- {
- QueryPerformanceCounter(¤tTicks);
- float timeScale = (float)(currentTicks.QuadPart-lastFrame.QuadPart)/((float)ticksPerSecond.QuadPart/targetFPS);
- if (timeScale <= 0.0d)
- timeScale = 1.0d;
- lastFrame = currentTicks;
- return timeScale; // Multiply this by all your movement and you're good.
- }
Add Comment
Please, Sign In to add comment