I want to be able to change the game speed, to speed up or slow down all animations and gameplay. Ideally, this could also be set to a negative number to make everything go backwards.
I tried this:
I made everything dependent on a time
variable, updated every frame from the OS time:
void calledEveryFrame()
{
time = System.accurateTime();
}
Then I tried just scaling that time.
lastTime = time;
long now = System.accurateTime();
double diff = now - lastTime;
time = (lastTime + diff * speed);
That obviously doesn't work, because you can't just multiply the speed times the difference because it is not called exactly regularly.
How do I do this correctly?