Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

enter image description here

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?

share|improve this question
up vote 2 down vote accepted

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).

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.