function(deltaTime) {
x = x * FACTOR; // FACTOR = 0.9
}
This function is called in a game loop. First assume that it’s running at a constant 30 FPS, so deltaTime is always 1/30.
Now the game is changed so deltaTime isn’t always 1/30 but becomes variable. How can I incorporate deltaTime in the calculation of x to keep the “effect per second” the same?
And what about
function(deltaTime) {
x += (target - x) * FACTOR; // FACTOR = 0.2
}
Edit
For your new update:
To show how I got there:
Let x0 be the initial value, and xn be the value after n/30 seconds. Also let T=target, F=factor. Then:
Continuing with x3,x4,… will show:
Now substituting the formula for the sum of a geometric sequence will give the result above. This really only proves the result for integer
n, but it should work for all values.