mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(Tween) Refactor update_tween and make it a static function
This commit is contained in:
parent
6c51889430
commit
ddd210d4f0
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user