Testing time (and found some bugs!)
Some checks failed
Build Dusk / build-linux (push) Has been cancelled
Build Dusk / build-psp (push) Has been cancelled
Build Dusk / run-tests (push) Has been cancelled

This commit is contained in:
2026-01-05 18:09:31 -06:00
parent 83b799caa8
commit 6cb80e9e23
5 changed files with 139 additions and 6 deletions

View File

@@ -33,16 +33,18 @@ void timeUpdate(void) {
#if TIME_FIXED == 0
#if TIME_SDL2
float_t newTime = (float_t)SDL_GetTicks() / 1000.0f;
TIME.dynamicDelta = newTime - TIME.dynamicTime;
TIME.dynamicTime = newTime;
float_t msElapsed = ((float_t)SDL_GetTicks64() / 1000.0f) + TIME_STEP;
TIME.dynamicDelta = msElapsed - TIME.dynamicTime;
TIME.dynamicTime = msElapsed;
TIME.dynamicUpdate = true;
#else
#error "No time platform defined"
#endif
assertTrue(TIME.dynamicDelta >= 0.0f, "Time delta is negative");
if(TIME.dynamicTime - TIME.time >= TIME_STEP) {
// Is within 1ms of a full step?
if(TIME.dynamicTime - TIME.time >= TIME_STEP * 0.999f) {
TIME.dynamicUpdate = false;
TIME.delta = TIME_STEP;
TIME.time += TIME_STEP;

View File

@@ -8,8 +8,7 @@
#pragma once
#include "dusk.h"
#define TIME_STEP (1.0f / 60.0f) // 60 Ticks per second (what we are aiming for)
#define TIME_STEP (16.0f / 1000.0f)
#ifndef TIME_FIXED
#define TIME_FIXED 0
#endif