diff --git a/src/internal.c b/src/internal.c index e6cd5de..4cf351b 100644 --- a/src/internal.c +++ b/src/internal.c @@ -28,6 +28,9 @@ SYMBOL_INTERNAL void DrawGamestates(struct Game* game) { ClearScreen(game); al_set_target_backbuffer(game->display); struct Gamestate* tmp = game->_priv.gamestates; + if (game->handlers.predraw) { + (*game->handlers.predraw)(game); + } while (tmp) { if ((tmp->loaded) && (tmp->started)) { game->_priv.current_gamestate = tmp; @@ -35,10 +38,16 @@ SYMBOL_INTERNAL void DrawGamestates(struct Game* game) { } tmp = tmp->next; } + if (game->handlers.postdraw) { + (*game->handlers.postdraw)(game); + } } SYMBOL_INTERNAL void LogicGamestates(struct Game* game, double delta) { struct Gamestate* tmp = game->_priv.gamestates; + if (game->handlers.prelogic) { + (*game->handlers.prelogic)(game, delta); + } while (tmp) { if ((tmp->loaded) && (tmp->started) && (!tmp->paused)) { game->_priv.current_gamestate = tmp; @@ -46,6 +55,9 @@ SYMBOL_INTERNAL void LogicGamestates(struct Game* game, double delta) { } tmp = tmp->next; } + if (game->handlers.postlogic) { + (*game->handlers.postlogic)(game, delta); + } } SYMBOL_INTERNAL void ReloadGamestates(struct Game* game) { diff --git a/src/libsuperderpy.c b/src/libsuperderpy.c index bb5f016..920f779 100644 --- a/src/libsuperderpy.c +++ b/src/libsuperderpy.c @@ -76,6 +76,10 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char* game->handlers.event = NULL; game->handlers.destroy = NULL; + game->handlers.prelogic = NULL; + game->handlers.postlogic = NULL; + game->handlers.predraw = NULL; + game->handlers.postdraw = NULL; game->config.fullscreen = strtol(GetConfigOptionDefault(game, "SuperDerpy", "fullscreen", "1"), NULL, 10); game->config.music = strtol(GetConfigOptionDefault(game, "SuperDerpy", "music", "10"), NULL, 10); diff --git a/src/libsuperderpy.h b/src/libsuperderpy.h index f8d303d..43c763d 100644 --- a/src/libsuperderpy.h +++ b/src/libsuperderpy.h @@ -143,6 +143,10 @@ struct Game { struct { bool (*event)(struct Game* game, ALLEGRO_EVENT* ev); void (*destroy)(struct Game* game); + void (*prelogic)(struct Game* game, double delta); + void (*postlogic)(struct Game* game, double delta); + void (*predraw)(struct Game* game); + void (*postdraw)(struct Game* game); } handlers; LIBSUPERDERPY_DATA_TYPE* data;