From 7bde25fe8411caa3607473de826a4494d796cff8 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Fri, 3 Aug 2018 13:15:06 +0200 Subject: [PATCH] add a public field with in-game total passed time --- src/libsuperderpy.c | 2 ++ src/libsuperderpy.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/libsuperderpy.c b/src/libsuperderpy.c index 928770c..1099ac9 100644 --- a/src/libsuperderpy.c +++ b/src/libsuperderpy.c @@ -430,6 +430,7 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) { (*game->_priv.loading.gamestate->api->Gamestate_Draw)(game, game->_priv.loading.gamestate->data); } game->_priv.loading.time += delta; + game->time += delta; // TODO: ability to disable passing time during loading if (game->_priv.texture_sync) { al_convert_memory_bitmaps(); game->_priv.texture_sync = false; @@ -508,6 +509,7 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) { double delta = al_get_time() - game->_priv.timestamp; game->_priv.timestamp += delta; delta *= ALLEGRO_BPS_TO_SECS(al_get_timer_speed(game->_priv.timer) / (1 / 60.f)); + game->time += delta; if (!game->_priv.paused) { LogicGamestates(game, delta); DrawGamestates(game); diff --git a/src/libsuperderpy.h b/src/libsuperderpy.h index 9a50551..029b43c 100644 --- a/src/libsuperderpy.h +++ b/src/libsuperderpy.h @@ -77,6 +77,8 @@ struct Game { struct Viewport viewport, viewport_config; + double time; /*!< In-game total passed time in seconds. */ + struct { int fx; /*!< Effects volume. */ int music; /*!< Music volume. */