One problem is that the amount of time per update may vary or be imprecise. If you base the calculation on the elapsed time you might get enough precision to arrive at the exact number 2250, but then again maybe not. How do you know, for example, that the 5 second point is the exact point at which the update happens?
Here is another idea. Make the update of the currentValue independent of the gameloop execution time. This can be done as follows:
(1) Keep track of elapsed time with every gameloop update.
(2) Don’t update the current value every update loop. Instead, test if the elapsed time has surpassed a defined required amount. Perhaps the updates only happen when a full second has elapsed, or this is done every half second or quarter second.
(3) Award the unit of current value that corresponds and reset the elapsed time.
Example:
if (elapsedTime > 1000)
{
currentValue += 450;
elapsedTime -= 1000;
}
Or, if every 1/10th of a second:
if (elapsedTime > 100)
{
currentValue += 45;
elapsedTime -= 100;
}
[Edit: this is the same idea as Varkas, basically. His post appeared while I was writing mine.]