(Tween) Refactor update_tween and make it a static function

This commit is contained in:
twinaphex 2014-10-10 19:36:17 +02:00
parent 6c51889430
commit ddd210d4f0
2 changed files with 7 additions and 14 deletions

View File

@ -40,12 +40,9 @@ void add_tween(float duration, float target_value, float* subject,
tween->callback = callback;
}
void update_tween(tween_t *tween, float dt)
static void update_tween(tween_t *tween, float dt, int *active_tweens)
{
if (!tween)
return;
if (tween->running_since < tween->duration)
if (tween && tween->running_since < tween->duration)
{
tween->running_since += dt;
@ -64,19 +61,17 @@ void update_tween(tween_t *tween, float dt)
tween->callback();
}
}
*active_tweens += tween->running_since < tween->duration ? 1 : 0;
}
void update_tweens(float dt)
{
int i, active_tweens;
active_tweens = 0;
int i;
int active_tweens = 0;
for(i = 0; i < numtweens; i++)
{
update_tween(&tweens[i], dt);
active_tweens += tweens[i].running_since < tweens[i].duration ? 1 : 0;
}
update_tween(&tweens[i], dt, &active_tweens);
if (numtweens && !active_tweens)
numtweens = 0;

View File

@ -39,8 +39,6 @@ typedef struct
void add_tween(float duration, float target_value,
float* subject, easingFunc easing, tweenCallback callback);
void update_tween(tween_t *data, float dt);
void update_tweens(float dt);
// from https://github.com/kikito/tween.lua/blob/master/tween.lua