mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-13 04:27:59 +01:00
add start event to timeline manager
This commit is contained in:
parent
85ae970597
commit
986378ec53
6 changed files with 72 additions and 66 deletions
|
@ -169,8 +169,19 @@ bool PassLevel(struct Game *game, struct TM_Action *action, enum TM_ActionState
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
|
if (state == TM_ACTIONSTATE_INIT) {
|
||||||
if (state == TM_ACTIONSTATE_DESTROY) {
|
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
|
||||||
|
float* f = (float*)action->arguments->value;
|
||||||
|
*f = 0;
|
||||||
|
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(ALLEGRO_AUDIO_STREAM*)));
|
||||||
|
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||||
|
*stream = al_load_audio_stream(GetDataFilePath(GetLevelFilename(game, "levels/?/letter.flac")), 4, 1024);
|
||||||
|
al_attach_audio_stream_to_mixer(*stream, game->audio.voice);
|
||||||
|
al_set_audio_stream_playing(*stream, false);
|
||||||
|
al_set_audio_stream_gain(*stream, 2.00);
|
||||||
|
action->arguments->next->next = NULL;
|
||||||
|
}
|
||||||
|
else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||||
al_set_audio_stream_playing(*stream, false);
|
al_set_audio_stream_playing(*stream, false);
|
||||||
al_destroy_audio_stream(*stream);
|
al_destroy_audio_stream(*stream);
|
||||||
|
@ -178,7 +189,7 @@ bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState sta
|
||||||
free(action->arguments->value);
|
free(action->arguments->value);
|
||||||
TM_DestroyArgs(action->arguments);
|
TM_DestroyArgs(action->arguments);
|
||||||
}
|
}
|
||||||
if (state == TM_ACTIONSTATE_DRAW) {
|
else if (state == TM_ACTIONSTATE_DRAW) {
|
||||||
float* f = (float*)action->arguments->value;
|
float* f = (float*)action->arguments->value;
|
||||||
al_draw_tinted_bitmap(game->level.letter, al_map_rgba(*f,*f,*f,*f), (game->viewportWidth-al_get_bitmap_width(game->level.letter))/2.0, al_get_bitmap_height(game->level.letter)*-0.05, 0);
|
al_draw_tinted_bitmap(game->level.letter, al_map_rgba(*f,*f,*f,*f), (game->viewportWidth-al_get_bitmap_width(game->level.letter))/2.0, al_get_bitmap_height(game->level.letter)*-0.05, 0);
|
||||||
return false;
|
return false;
|
||||||
|
@ -190,19 +201,11 @@ bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState sta
|
||||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||||
al_set_audio_stream_playing(*stream, true);
|
al_set_audio_stream_playing(*stream, true);
|
||||||
}
|
}
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
else if (state == TM_ACTIONSTATE_START) {
|
||||||
if (!action->arguments) {
|
|
||||||
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
|
|
||||||
float* f = (float*)action->arguments->value;
|
|
||||||
*f = 0;
|
|
||||||
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(ALLEGRO_AUDIO_STREAM*)));
|
|
||||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||||
*stream = al_load_audio_stream(GetDataFilePath(GetLevelFilename(game, "levels/?/letter.flac")), 4, 1024);
|
|
||||||
al_attach_audio_stream_to_mixer(*stream, game->audio.voice);
|
|
||||||
al_set_audio_stream_playing(*stream, true);
|
al_set_audio_stream_playing(*stream, true);
|
||||||
al_set_audio_stream_gain(*stream, 2.00);
|
|
||||||
action->arguments->next->next = NULL;
|
|
||||||
}
|
}
|
||||||
|
else if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
float* f = (float*)action->arguments->value;
|
float* f = (float*)action->arguments->value;
|
||||||
*f+=5;
|
*f+=5;
|
||||||
if (*f>255) *f=255;
|
if (*f>255) *f=255;
|
||||||
|
|
|
@ -27,7 +27,9 @@
|
||||||
|
|
||||||
void Level6_Load(struct Game *game) {
|
void Level6_Load(struct Game *game) {
|
||||||
Moonwalk_Load(game);
|
Moonwalk_Load(game);
|
||||||
TM_AddBackgroundAction(&PassLevel, NULL, 5000, "passlevel");
|
TM_AddAction(&DoMoonwalk, NULL, "moonwalk");
|
||||||
|
TM_AddBackgroundAction(&DoMoonwalk, NULL, 5000, "moonwalkDerp");
|
||||||
|
TM_AddBackgroundAction(&PassLevel, NULL, 10000, "passlevel");
|
||||||
FadeGameState(game, true);
|
FadeGameState(game, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,76 +28,67 @@
|
||||||
bool Accelerate(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool Accelerate(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
game->level.speed+=0.000015;
|
game->level.speed+=0.000015;
|
||||||
if (game->level.speed<0.0025) return false;
|
if (game->level.speed>=0.0025) return true;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make it configurable and move to generic actions
|
// TODO: make it configurable and move to generic actions
|
||||||
bool Walk(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool Walk(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
|
if (state == TM_ACTIONSTATE_START) SelectDerpySpritesheet(game, "walk");
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
else if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
if (!(action->arguments)) SelectDerpySpritesheet(game, "walk");
|
|
||||||
action->arguments++;
|
|
||||||
game->level.derpy_x+=0.001;
|
game->level.derpy_x+=0.001;
|
||||||
if (game->level.derpy_x<0.05) return false;
|
if (game->level.derpy_x>=0.05) return true;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make it configurable and move to generic actions
|
// TODO: make it configurable and move to generic actions
|
||||||
bool Move(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool Move(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
game->level.speed=0.000345;
|
game->level.speed=0.000345;
|
||||||
if (game->level.st_pos<0.275) return false;
|
if (game->level.st_pos>=0.275) return true;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Fly(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool Fly(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
|
if (state == TM_ACTIONSTATE_START) {
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
|
||||||
if (!(action->arguments)) {
|
|
||||||
SelectDerpySpritesheet(game, "fly");
|
SelectDerpySpritesheet(game, "fly");
|
||||||
game->level.derpy_angle = -0.15;
|
game->level.derpy_angle = -0.15;
|
||||||
/*game->level.gg = true;*/
|
|
||||||
TM_AddBackgroundAction(&ShowMeter, NULL, 0, "showmeter");
|
TM_AddBackgroundAction(&ShowMeter, NULL, 0, "showmeter");
|
||||||
action->arguments++;
|
|
||||||
}
|
}
|
||||||
|
else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||||
|
game->level.handle_input = true;
|
||||||
|
}
|
||||||
|
else if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
game->level.derpy_y-=0.004;
|
game->level.derpy_y-=0.004;
|
||||||
if (game->level.derpy_y>0.2) return false;
|
if (game->level.derpy_y<=0.2) return true;
|
||||||
game->level.handle_input=true;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Run(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool Run(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
|
if (state == TM_ACTIONSTATE_START) {
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
|
||||||
if (!(action->arguments)) {
|
|
||||||
game->level.handle_input=false;
|
game->level.handle_input=false;
|
||||||
game->level.speed_modifier=1;
|
game->level.speed_modifier=1;
|
||||||
action->arguments++;
|
|
||||||
}
|
}
|
||||||
|
else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||||
|
game->level.derpy_angle = 0;
|
||||||
|
SelectDerpySpritesheet(game, "run");
|
||||||
|
}
|
||||||
|
else if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
game->level.derpy_y+=0.0042;
|
game->level.derpy_y+=0.0042;
|
||||||
if (game->level.derpy_angle > 0) { game->level.derpy_angle -= 0.02; if (game->level.derpy_angle < 0) game->level.derpy_angle = 0; }
|
if (game->level.derpy_angle > 0) { game->level.derpy_angle -= 0.02; if (game->level.derpy_angle < 0) game->level.derpy_angle = 0; }
|
||||||
if (game->level.derpy_angle < 0) { game->level.derpy_angle += 0.02; if (game->level.derpy_angle > 0) game->level.derpy_angle = 0; }
|
if (game->level.derpy_angle < 0) { game->level.derpy_angle += 0.02; if (game->level.derpy_angle > 0) game->level.derpy_angle = 0; }
|
||||||
if (game->level.derpy_y<0.65) return false;
|
if (game->level.derpy_y>=0.65) return true;
|
||||||
game->level.derpy_angle = 0;
|
return false;
|
||||||
SelectDerpySpritesheet(game, "run");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
/*float* tmp; bool* in;*/
|
|
||||||
int* count;
|
int* count;
|
||||||
if (!action->arguments) {
|
if (!action->arguments) {
|
||||||
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(int)));
|
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(int)));
|
||||||
/* action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(bool))); */
|
|
||||||
}
|
}
|
||||||
count = (int*)action->arguments->value;
|
count = (int*)action->arguments->value;
|
||||||
/*tmp = (float*)action->arguments->value;
|
|
||||||
in = (bool*)action->arguments->next->value;*/
|
|
||||||
if (state == TM_ACTIONSTATE_INIT) {
|
if (state == TM_ACTIONSTATE_INIT) {
|
||||||
*count = 0;
|
*count = 0;
|
||||||
/* *tmp = 0;
|
|
||||||
*in = true;*/
|
|
||||||
}
|
}
|
||||||
else if (state == TM_ACTIONSTATE_RUNNING) {
|
else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||||
if (rand()%(10000/(int)(85*game->level.speed_modifier))<=3) {
|
if (rand()%(10000/(int)(85*game->level.speed_modifier))<=3) {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
// TODO: use Walk action instead
|
// TODO: use Walk action instead
|
||||||
bool DoMoonwalk(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool DoMoonwalk(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (state == TM_ACTIONSTATE_INIT) {
|
if (state == TM_ACTIONSTATE_START) {
|
||||||
SelectDerpySpritesheet(game, "walk");
|
SelectDerpySpritesheet(game, "walk");
|
||||||
game->level.sheet_speed_modifier = 0.94;
|
game->level.sheet_speed_modifier = 0.94;
|
||||||
game->level.moonwalk.derpy_pos = -0.2;
|
game->level.moonwalk.derpy_pos = -0.2;
|
||||||
|
|
|
@ -41,6 +41,10 @@ void TM_Process() {
|
||||||
if returns true, delete it */
|
if returns true, delete it */
|
||||||
if (queue) {
|
if (queue) {
|
||||||
if (*queue->function) {
|
if (*queue->function) {
|
||||||
|
if (!queue->active) {
|
||||||
|
PrintConsole(game, "Timeline Manager: queue: run action (%d - %s)", queue->id, queue->name);
|
||||||
|
(*queue->function)(game, queue, TM_ACTIONSTATE_START);
|
||||||
|
}
|
||||||
queue->active = true;
|
queue->active = true;
|
||||||
if ((*queue->function)(game, queue, TM_ACTIONSTATE_RUNNING)) {
|
if ((*queue->function)(game, queue, TM_ACTIONSTATE_RUNNING)) {
|
||||||
PrintConsole(game, "Timeline Manager: queue: destroy action (%d - %s)", queue->id, queue->name);
|
PrintConsole(game, "Timeline Manager: queue: destroy action (%d - %s)", queue->id, queue->name);
|
||||||
|
@ -50,7 +54,6 @@ void TM_Process() {
|
||||||
(*tmp->function)(game, tmp, TM_ACTIONSTATE_DESTROY);
|
(*tmp->function)(game, tmp, TM_ACTIONSTATE_DESTROY);
|
||||||
free(tmp->name);
|
free(tmp->name);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
if (queue) PrintConsole(game, "Timeline Manager: queue: run action (%d - %s)", queue->id, queue->name);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* delay handling */
|
/* delay handling */
|
||||||
|
@ -59,9 +62,11 @@ void TM_Process() {
|
||||||
queue = queue->next;
|
queue = queue->next;
|
||||||
free(tmp->name);
|
free(tmp->name);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
if (queue) PrintConsole(game, "Timeline Manager: queue: run action (%d - %s)", queue->id, queue->name);
|
|
||||||
} else {
|
} else {
|
||||||
al_start_timer(queue->timer);
|
if (!al_get_timer_started(queue->timer)) {
|
||||||
|
PrintConsole(game, "Timeline Manager: queue: delay started %d ms (%d - %s)", queue->delay, queue->id, queue->name);
|
||||||
|
al_start_timer(queue->timer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,8 +172,8 @@ void TM_HandleEvent(ALLEGRO_EVENT *ev) {
|
||||||
al_destroy_timer(queue->timer);
|
al_destroy_timer(queue->timer);
|
||||||
queue->timer = NULL;
|
queue->timer = NULL;
|
||||||
if (queue->function) {
|
if (queue->function) {
|
||||||
PrintConsole(game, "Timeline Manager: queue: init action (%d - %s)", queue->id, queue->name);
|
PrintConsole(game, "Timeline Manager: queue: run action (%d - %s)", queue->id, queue->name);
|
||||||
(*queue->function)(game, queue, TM_ACTIONSTATE_INIT);
|
(*queue->function)(game, queue, TM_ACTIONSTATE_START);
|
||||||
} else {
|
} else {
|
||||||
PrintConsole(game, "Timeline Manager: queue: delay reached (%d - %s)", queue->id, queue->name);
|
PrintConsole(game, "Timeline Manager: queue: delay reached (%d - %s)", queue->id, queue->name);
|
||||||
}
|
}
|
||||||
|
@ -178,11 +183,11 @@ void TM_HandleEvent(ALLEGRO_EVENT *ev) {
|
||||||
struct TM_Action *pom = background;
|
struct TM_Action *pom = background;
|
||||||
while (pom) {
|
while (pom) {
|
||||||
if (ev->timer.source == pom->timer) {
|
if (ev->timer.source == pom->timer) {
|
||||||
PrintConsole(game, "Timeline Manager: background: delay reached, init and run action (%d - %s)", pom->id, pom->name);
|
PrintConsole(game, "Timeline Manager: background: delay reached, run action (%d - %s)", pom->id, pom->name);
|
||||||
pom->active=true;
|
pom->active=true;
|
||||||
al_destroy_timer(pom->timer);
|
al_destroy_timer(pom->timer);
|
||||||
pom->timer = NULL;
|
pom->timer = NULL;
|
||||||
(*pom->function)(game, pom, TM_ACTIONSTATE_INIT);
|
(*pom->function)(game, pom, TM_ACTIONSTATE_START);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pom=pom->next;
|
pom=pom->next;
|
||||||
|
@ -216,7 +221,7 @@ struct TM_Action* TM_AddAction(bool (*func)(struct Game*, struct TM_Action*, enu
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TM_Action* TM_AddBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, float delay, char* name) {
|
struct TM_Action* TM_AddBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, int delay, char* name) {
|
||||||
struct TM_Action *action = malloc(sizeof(struct TM_Action));
|
struct TM_Action *action = malloc(sizeof(struct TM_Action));
|
||||||
if (background) {
|
if (background) {
|
||||||
struct TM_Action *pom = background;
|
struct TM_Action *pom = background;
|
||||||
|
@ -235,15 +240,19 @@ struct TM_Action* TM_AddBackgroundAction(bool (*func)(struct Game*, struct TM_Ac
|
||||||
action->delay = delay;
|
action->delay = delay;
|
||||||
action->id = ++lastid;
|
action->id = ++lastid;
|
||||||
if (delay) {
|
if (delay) {
|
||||||
|
PrintConsole(game, "Timeline Manager: background: init action with delay %d ms (%d - %s)", delay, action->id, action->name);
|
||||||
|
(*action->function)(game, action, TM_ACTIONSTATE_INIT);
|
||||||
action->active = false;
|
action->active = false;
|
||||||
action->timer = al_create_timer(delay/1000.0);
|
action->timer = al_create_timer(delay/1000.0);
|
||||||
al_register_event_source(game->event_queue, al_get_timer_event_source(action->timer));
|
al_register_event_source(game->event_queue, al_get_timer_event_source(action->timer));
|
||||||
al_start_timer(action->timer);
|
al_start_timer(action->timer);
|
||||||
} else {
|
} else {
|
||||||
|
PrintConsole(game, "Timeline Manager: background: init action (%d - %s)", action->id, action->name);
|
||||||
|
(*action->function)(game, action, TM_ACTIONSTATE_INIT);
|
||||||
action->timer = NULL;
|
action->timer = NULL;
|
||||||
action->active = true;
|
action->active = true;
|
||||||
PrintConsole(game, "Timeline Manager: background: init and run action (%d - %s)", action->id, action->name);
|
PrintConsole(game, "Timeline Manager: background: run action (%d - %s)", action->id, action->name);
|
||||||
(*action->function)(game, action, TM_ACTIONSTATE_INIT);
|
(*action->function)(game, action, TM_ACTIONSTATE_START);
|
||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
@ -251,18 +260,18 @@ struct TM_Action* TM_AddBackgroundAction(bool (*func)(struct Game*, struct TM_Ac
|
||||||
/*! \brief Predefined action used by TM_AddQueuedBackgroundAction */
|
/*! \brief Predefined action used by TM_AddQueuedBackgroundAction */
|
||||||
bool runinbackground(struct Game* game, struct TM_Action* action, enum TM_ActionState state) {
|
bool runinbackground(struct Game* game, struct TM_Action* action, enum TM_ActionState state) {
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
float* delay = (float*) action->arguments->next->value;
|
int* delay = (int*) action->arguments->next->value;
|
||||||
char* name = (char*) action->arguments->next->next->value;
|
char* name = (char*) action->arguments->next->next->value;
|
||||||
TM_AddBackgroundAction(action->arguments->value, action->arguments->next->next->next, *delay, name);
|
TM_AddBackgroundAction(action->arguments->value, action->arguments->next->next->next, *delay, name);
|
||||||
free(name);
|
free(name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TM_Action* TM_AddQueuedBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, float delay, char* name) {
|
struct TM_Action* TM_AddQueuedBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, int delay, char* name) {
|
||||||
struct TM_Arguments* arguments = TM_AddToArgs(NULL, (void*) func);
|
struct TM_Arguments* arguments = TM_AddToArgs(NULL, (void*) func);
|
||||||
arguments = TM_AddToArgs(arguments, malloc(sizeof(float)));
|
arguments = TM_AddToArgs(arguments, malloc(sizeof(int)));
|
||||||
arguments = TM_AddToArgs(arguments, NULL);
|
arguments = TM_AddToArgs(arguments, NULL);
|
||||||
*(float*)(arguments->next->value) = delay;
|
*(int*)(arguments->next->value) = delay;
|
||||||
arguments->next->next->value = malloc((strlen(name)+1)*sizeof(char));
|
arguments->next->next->value = malloc((strlen(name)+1)*sizeof(char));
|
||||||
strcpy(arguments->next->next->value, name);
|
strcpy(arguments->next->next->value, name);
|
||||||
|
|
||||||
|
@ -270,13 +279,13 @@ struct TM_Action* TM_AddQueuedBackgroundAction(bool (*func)(struct Game*, struct
|
||||||
return TM_AddAction(*runinbackground, arguments, "TM_BackgroundAction");
|
return TM_AddAction(*runinbackground, arguments, "TM_BackgroundAction");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TM_AddDelay(float delay) {
|
void TM_AddDelay(int delay) {
|
||||||
/*int *tmp;
|
/*int *tmp;
|
||||||
tmp = malloc(sizeof(int));
|
tmp = malloc(sizeof(int));
|
||||||
*tmp = delay;
|
*tmp = delay;
|
||||||
TM_AddAction(NULL, TM_AddToArgs(NULL, tmp));*/
|
TM_AddAction(NULL, TM_AddToArgs(NULL, tmp));*/
|
||||||
struct TM_Action* tmp = TM_AddAction(NULL, NULL, "TM_Delay");
|
struct TM_Action* tmp = TM_AddAction(NULL, NULL, "TM_Delay");
|
||||||
PrintConsole(game, "Timeline Manager: queue: adding delay %f ms (%d)", delay, tmp->id);
|
PrintConsole(game, "Timeline Manager: queue: adding delay %d ms (%d)", delay, tmp->id);
|
||||||
tmp->delay = delay;
|
tmp->delay = delay;
|
||||||
tmp->timer = al_create_timer(delay/1000.0);
|
tmp->timer = al_create_timer(delay/1000.0);
|
||||||
al_register_event_source(game->event_queue, al_get_timer_event_source(tmp->timer));
|
al_register_event_source(game->event_queue, al_get_timer_event_source(tmp->timer));
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
/*! \brief State of the TM_Action. */
|
/*! \brief State of the TM_Action. */
|
||||||
enum TM_ActionState {
|
enum TM_ActionState {
|
||||||
TM_ACTIONSTATE_INIT,
|
TM_ACTIONSTATE_INIT,
|
||||||
|
TM_ACTIONSTATE_START,
|
||||||
TM_ACTIONSTATE_RUNNING,
|
TM_ACTIONSTATE_RUNNING,
|
||||||
TM_ACTIONSTATE_DRAW,
|
TM_ACTIONSTATE_DRAW,
|
||||||
TM_ACTIONSTATE_DESTROY,
|
TM_ACTIONSTATE_DESTROY,
|
||||||
|
@ -66,11 +67,11 @@ void TM_HandleEvent(ALLEGRO_EVENT *ev);
|
||||||
/*! \brief Add new action to main queue. */
|
/*! \brief Add new action to main queue. */
|
||||||
struct TM_Action* TM_AddAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, char* name);
|
struct TM_Action* TM_AddAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, char* name);
|
||||||
/*! \brief Add new action to background queue. */
|
/*! \brief Add new action to background queue. */
|
||||||
struct TM_Action* TM_AddBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, float delay, char* name);
|
struct TM_Action* TM_AddBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, int delay, char* name);
|
||||||
/*! \brief Add new action to main queue, which adds specified action into background queue. */
|
/*! \brief Add new action to main queue, which adds specified action into background queue. */
|
||||||
struct TM_Action* TM_AddQueuedBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, float delay, char* name);
|
struct TM_Action* TM_AddQueuedBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, int delay, char* name);
|
||||||
/*! \brief Add delay to main queue. */
|
/*! \brief Add delay to main queue. */
|
||||||
void TM_AddDelay(float delay);
|
void TM_AddDelay(int delay);
|
||||||
/*! \brief Destroy timeline. */
|
/*! \brief Destroy timeline. */
|
||||||
void TM_Destroy();
|
void TM_Destroy();
|
||||||
/*! \brief Add data to TM_Arguments queue. */
|
/*! \brief Add data to TM_Arguments queue. */
|
||||||
|
|
Loading…
Reference in a new issue