mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
implement TM_AddToArgs
This commit is contained in:
parent
314429a2fe
commit
db056c3a2a
2 changed files with 26 additions and 20 deletions
22
src/level.c
22
src/level.c
|
@ -51,11 +51,8 @@ void Level_Draw(struct Game *game) {
|
||||||
|
|
||||||
bool FadeIn(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool FadeIn(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (!action->arguments) {
|
if (!action->arguments) {
|
||||||
action->arguments = malloc(sizeof(struct TM_Arguments));
|
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
|
||||||
action->arguments->value = malloc(sizeof(float));
|
action->arguments = TM_AddToArgs(action->arguments, (void*)al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)));
|
||||||
action->arguments->next = malloc(sizeof(struct TM_Arguments));
|
|
||||||
action->arguments->next->value = (void*)al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
|
||||||
action->arguments->next->next = NULL;
|
|
||||||
}
|
}
|
||||||
float* fadeloop;
|
float* fadeloop;
|
||||||
ALLEGRO_BITMAP* fade_bitmap;
|
ALLEGRO_BITMAP* fade_bitmap;
|
||||||
|
@ -81,11 +78,8 @@ bool FadeIn(struct Game *game, struct TM_Action *action, enum TM_ActionState sta
|
||||||
|
|
||||||
bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (!action->arguments) {
|
if (!action->arguments) {
|
||||||
action->arguments = malloc(sizeof(struct TM_Arguments));
|
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
|
||||||
action->arguments->value = malloc(sizeof(float));
|
action->arguments = TM_AddToArgs(action->arguments, (void*)al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)));
|
||||||
action->arguments->next = malloc(sizeof(struct TM_Arguments));
|
|
||||||
action->arguments->next->value = (void*)al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
|
||||||
action->arguments->next->next = NULL;
|
|
||||||
}
|
}
|
||||||
float* fadeloop;
|
float* fadeloop;
|
||||||
ALLEGRO_BITMAP* fade_bitmap;
|
ALLEGRO_BITMAP* fade_bitmap;
|
||||||
|
@ -114,9 +108,7 @@ bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState st
|
||||||
|
|
||||||
bool napis2(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool napis2(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (!action->arguments) {
|
if (!action->arguments) {
|
||||||
action->arguments = malloc(sizeof(struct TM_Arguments));
|
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(int)));
|
||||||
action->arguments->value = malloc(sizeof(int));
|
|
||||||
action->arguments->next = NULL;
|
|
||||||
}
|
}
|
||||||
int* tmp;
|
int* tmp;
|
||||||
tmp = (int*)action->arguments->value;
|
tmp = (int*)action->arguments->value;
|
||||||
|
@ -135,9 +127,7 @@ bool napis2(struct Game *game, struct TM_Action *action, enum TM_ActionState sta
|
||||||
|
|
||||||
bool napis(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
bool napis(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||||
if (!action->arguments) {
|
if (!action->arguments) {
|
||||||
action->arguments = malloc(sizeof(struct TM_Arguments));
|
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(int)));
|
||||||
action->arguments->value = malloc(sizeof(int));
|
|
||||||
action->arguments->next = NULL;
|
|
||||||
}
|
}
|
||||||
int* tmp;
|
int* tmp;
|
||||||
tmp = (int*)action->arguments->value;
|
tmp = (int*)action->arguments->value;
|
||||||
|
|
|
@ -128,9 +128,13 @@ void TM_AddBackgroundAction(bool (*func)(struct Game*, struct TM_Action*, enum T
|
||||||
action->function = func;
|
action->function = func;
|
||||||
action->arguments = args;
|
action->arguments = args;
|
||||||
action->timer = NULL; // TODO
|
action->timer = NULL; // TODO
|
||||||
action->active = true; // TODO: false here, true when delay
|
|
||||||
action->delay = delay;
|
action->delay = delay;
|
||||||
(*action->function)(game, action, TM_ACTIONSTATE_INIT); // TODO: move to TM_HandleEvent
|
if (delay) {
|
||||||
|
action->active = false;
|
||||||
|
} else {
|
||||||
|
action->active = true;
|
||||||
|
(*action->function)(game, action, TM_ACTIONSTATE_INIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TM_AddDelay(int delay) {
|
void TM_AddDelay(int delay) {
|
||||||
|
@ -195,8 +199,20 @@ void TM_Destroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TM_Arguments* TM_AddToArgs(struct TM_Arguments* args, void* arg) {
|
struct TM_Arguments* TM_AddToArgs(struct TM_Arguments* args, void* arg) {
|
||||||
// TODO
|
struct TM_Arguments* tmp;
|
||||||
return NULL;
|
if (!args) {
|
||||||
|
tmp = malloc(sizeof(struct TM_Arguments));
|
||||||
|
tmp->value = arg;
|
||||||
|
tmp->next = NULL;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
while (tmp->next) {
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
tmp->next = malloc(sizeof(struct TM_Arguments));
|
||||||
|
tmp->next->value = arg;
|
||||||
|
tmp->next->next = NULL;
|
||||||
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TM_DestroyArgs(struct TM_Arguments* args) {
|
void TM_DestroyArgs(struct TM_Arguments* args) {
|
||||||
|
|
Loading…
Reference in a new issue