From f0868c7a293d4fa4222b502e7e4e592575790a75 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 26 Apr 2016 08:16:15 +0100 Subject: [PATCH] Reset delta time when ending a transition. --- src/main.c | 7 +++++++ src/structs.h | 1 + src/system/transition.c | 2 ++ src/system/transition.h | 2 ++ 4 files changed, 12 insertions(+) diff --git a/src/main.c b/src/main.c index 63039e4..cde5fe9 100644 --- a/src/main.c +++ b/src/main.c @@ -103,8 +103,15 @@ int main(int argc, char *argv[]) while (td >= LOGIC_RATE) { app.delegate.logic(); + td -= LOGIC_RATE; + if (app.resetTimeDelta) + { + td = 0; + then = SDL_GetTicks(); + } + game.stats[STAT_TIME]++; } diff --git a/src/structs.h b/src/structs.h index 965b4f2..2d33e14 100644 --- a/src/structs.h +++ b/src/structs.h @@ -443,6 +443,7 @@ typedef struct { } Mouse; typedef struct { + int resetTimeDelta; char saveDir[MAX_FILENAME_LENGTH]; int winWidth; int winHeight; diff --git a/src/system/transition.c b/src/system/transition.c index 06991b6..c9d74b2 100644 --- a/src/system/transition.c +++ b/src/system/transition.c @@ -43,4 +43,6 @@ void endSectionTransition(void) { SDL_Delay(elasped); } + + app.resetTimeDelta = 1; } diff --git a/src/system/transition.h b/src/system/transition.h index c6fd9b3..9b79f94 100644 --- a/src/system/transition.h +++ b/src/system/transition.h @@ -24,3 +24,5 @@ extern void prepareScene(void); extern void presentScene(void); extern void clearInput(void); extern void expireTexts(int all); + +extern App app;