add a public field with in-game total passed time

This commit is contained in:
Sebastian Krzyszkowiak 2018-08-03 13:15:06 +02:00
parent 341aa1d823
commit 7bde25fe84
2 changed files with 4 additions and 0 deletions

View file

@ -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.gamestate->api->Gamestate_Draw)(game, game->_priv.loading.gamestate->data);
} }
game->_priv.loading.time += delta; game->_priv.loading.time += delta;
game->time += delta; // TODO: ability to disable passing time during loading
if (game->_priv.texture_sync) { if (game->_priv.texture_sync) {
al_convert_memory_bitmaps(); al_convert_memory_bitmaps();
game->_priv.texture_sync = false; game->_priv.texture_sync = false;
@ -508,6 +509,7 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) {
double delta = al_get_time() - game->_priv.timestamp; double delta = al_get_time() - game->_priv.timestamp;
game->_priv.timestamp += delta; game->_priv.timestamp += delta;
delta *= ALLEGRO_BPS_TO_SECS(al_get_timer_speed(game->_priv.timer) / (1 / 60.f)); delta *= ALLEGRO_BPS_TO_SECS(al_get_timer_speed(game->_priv.timer) / (1 / 60.f));
game->time += delta;
if (!game->_priv.paused) { if (!game->_priv.paused) {
LogicGamestates(game, delta); LogicGamestates(game, delta);
DrawGamestates(game); DrawGamestates(game);

View file

@ -77,6 +77,8 @@ struct Game {
struct Viewport viewport, viewport_config; struct Viewport viewport, viewport_config;
double time; /*!< In-game total passed time in seconds. */
struct { struct {
int fx; /*!< Effects volume. */ int fx; /*!< Effects volume. */
int music; /*!< Music volume. */ int music; /*!< Music volume. */