Still working on my scrolling text and bug fixing.

This commit is contained in:
2021-07-16 22:26:04 -07:00
parent 96e66901ff
commit 595eacef0f
26 changed files with 495 additions and 115 deletions

View File

@ -7,17 +7,12 @@
#include "timeline.h"
void onDone(timeline_t *test) {
}
void timelineInit(timeline_t *timeline) {
timeline->current = 0;
timeline->diff = 0;
timeline->previous = 0;
timeline->user = 0;
timeline->actionCount = 0;
timeline->actions[0].onStart = &onDone;
}
void timelineUpdate(timeline_t *timeline, float delta) {
@ -38,7 +33,7 @@ void timelineUpdate(timeline_t *timeline, float delta) {
// Did we start this frame?
if(action->start > timeline->previous && action->onStart != NULL) {
action->onStart(timeline);
action->onStart(timeline, action, i);
}
// Durations of 0 only fire starts, never ends or durations.
@ -47,9 +42,10 @@ void timelineUpdate(timeline_t *timeline, float delta) {
// Is the end still in the future? Durations in negatives go forever
full = action->start+action->duration;
if(action->duration < 0 || full > timeline->current) {
if(action->onDuration != NULL) action->onDuration(timeline);
if(action->onDuration != NULL) action->onDuration(timeline, action, i);
} else if(full > timeline->previous) {// Did we end this frame?
if(action->onEnd != NULL) action->onEnd(timeline);
if(action->onEnd != NULL) action->onEnd(timeline, action, i);
if(action->loop) action->start = timeline->current;
}
}
}
@ -74,6 +70,7 @@ timelineaction_t * timelineAddAction(timeline_t *timeline, float start,
) {
if(timeline->actionCount == TIMELINE_ACTION_COUNT_MAX) return NULL;
timelineaction_t *action = timeline->actions + (timeline->actionCount++);
action->loop = false;
action->start = start, action->duration = duration;
action->onStart = action->onEnd = action->onDuration = NULL;
return action;