fix: not calculating the correct amount of seconds

This commit is contained in:
2025-03-22 17:32:55 +01:00
parent e35588d9ea
commit bcbf62b1a7

View File

@@ -28,7 +28,7 @@ atrb_const static inline gametime gametime_new(void) {
static inline void gametime_update(gametime* gt) { static inline void gametime_update(gametime* gt) {
struct timespec ts; struct timespec ts;
timespec_get(&ts, TIME_UTC); timespec_get(&ts, TIME_UTC);
gt->sec = (double)ts.tv_nsec * 1e-9; // calculate the current time in seconds gt->sec = (double)ts.tv_nsec * 1e-9 + ts.tv_sec; // calculate the current time in seconds
gt->delta = ((double)(ts.tv_nsec - gt->ts.tv_nsec) * 1e-9) * gt->scale; // calculate how much time has passed between this and last frame gt->delta = ((double)(ts.tv_nsec - gt->ts.tv_nsec) * 1e-9) * gt->scale; // calculate how much time has passed between this and last frame
gt->ts = ts; // update the game's timespec gt->ts = ts; // update the game's timespec
} }