Cleaned the timeline code up nicely.

This commit is contained in:
2021-07-15 09:26:31 -07:00
parent 9e40d8f576
commit 06202f6f7e
4 changed files with 35 additions and 31 deletions

View File

@ -72,6 +72,7 @@ bool timelineIsFinished(timeline_t *timeline) {
timelineaction_t * timelineAddAction(timeline_t *timeline, float start,
float duration
) {
if(timeline->actionCount == TIMELINE_ACTION_COUNT_MAX) return NULL;
timelineaction_t *action = timeline->actions + (timeline->actionCount++);
action->start = start, action->duration = duration;
action->onStart = action->onEnd = action->onDuration = NULL;

View File

@ -6,10 +6,38 @@
#pragma once
#include <dawn/dawn.h>
/**
* Initializes a timeline back to its default state.
*
* @param timeline Timeline to initialize.
*/
void timelineInit(timeline_t *timeline);
/**
* Ticks the timeline. This can be done using any delta.
*
* @param timeline Timeline to tick
* @param delta Delta to tick.
*/
void timelineUpdate(timeline_t *timeline, float delta);
/**
* Returns true if every action in the timeline has finished.
*
* @param timeline Timeline to check
* @return True if finished, otherwise false.
*/
bool timelineIsFinished(timeline_t *timeline);
/**
* Adds an action to the timeline. This will initialize the action callbacks to
* NULL, you will need to initialize your own callbacks.
*
* @param timeline Timeline to add to.
* @param start Start time.
* @param duration Duration time
* @return Pointer to the timeline action or NULL if the list is full.
*/
timelineaction_t * timelineAddAction(timeline_t *timeline, float start,
float duration
);