I've made two scripts for progress management: one for linear progress and one for parabolic progress. The concept for linear progress is very simple. You define a "initial state" and "intended state", and then a "progression position". It will then linearly go from one to another.
A simple example would be in the step event:
while (self.iter < 1000) { self.iter += 1; self.x = linear_progression(10, 20, self.iter / 1000); }
In the code above, the object x would go from 10 to 20, linearly, and take 1000 steps to do it.
Another piece of code I wrote are parabolic progressions. In this case, there is also an initial state and a "position", but instead of "intended state" there is a "middle state", that is, the state of the progression when position is 0.5. In my code, I use this for jumps.
I would also like to have cubic progressions, which would behave very similarly to linear progressions.
Anyway, here are the scripts:
linear_progression.gml (initial, final, t)
return argument0 + (argument1 - argument0) * argument2; parabolic_progression.gml (initial, middle, t)
var a; a = 4 * (argument0 - argument1);
return a * argument2 * argument2 - a * argument2 + argument0; Hope this is useful for the rest of you.
|