# Game speed cubic growth

Is it possible, using delta in my update method to increase a game speed variable exponentially on cubic growth (the blue line below)

My maths isn't great so I'm not sure how the formula would be put into practice using a `float gameSpeed` and delta in an update method `-(void) update:(ccTime)delta` I think I would also need a value to control the speed of the growth too?

-

Probably the most robust way is to store a linearly-growing `gameTime` value that you can update by just adding the delta to it each frame, then set `gameSpeed = someConstant * pow(gameTime, 3.0)` each frame.

But if you want to be able to do something interesting like changing the power continuously in real time, you could use the derivative: if y = t^n (in your case n = 3) then dy = nt^(n-1) dt = ny^((n-1)/n) dt, so you'd implement an update method like

``````power = 3.0;   // Or whatever power you want; it could even change over time
gameSpeed += someConstant * delta * power * pow(gameSpeed, (power - 1.0) / power);
``````

That should cause `gameSpeed` to grow approximately as time cubed, but you could also alter the power to increase or decrease the rate of acceleration (or make it slow down again, using a negative power).

-
Thank you, excellent answer. Could you explain what someConstant is for please. – Lewis Jul 6 '12 at 19:08
@Lewis `someConstant` is just a global constant factor you can tune to scale the overall rate of growth. – Nathan Reed Jul 6 '12 at 19:54