From ed0cfcc895a6c2407c0fff3bf23d7d934e6a1b25 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Sat, 14 Sep 2024 10:27:55 +1000 Subject: [PATCH] use ns for timing --- src/analogue.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/analogue.c b/src/analogue.c index 2640771..2272576 100644 --- a/src/analogue.c +++ b/src/analogue.c @@ -68,7 +68,7 @@ int SDL_AppInit(int argc, char* argv[]) InitDefaults(&stickl); InitDefaults(&stickr); - tickslast = SDL_GetTicks(); + tickslast = SDL_GetTicksNS(); return 0; } @@ -203,9 +203,8 @@ int SDL_AppEvent(const SDL_Event* event) int SDL_AppIterate(void) { - //FIXME: probably doesn't matter but this isn't very precise - const Uint64 ticks = SDL_GetTicks(); - const double framedelta = (double)(ticks - tickslast); + const Uint64 ticks = SDL_GetTicksNS(); + const double framedelta = (double)(ticks - tickslast) / 1000000000.0; tickslast = ticks; if (!repaint) @@ -225,7 +224,7 @@ int SDL_AppIterate(void) const int plrSz = 32; const int hplrSz = plrSz / 2; - plrpos = VecAdd(plrpos, VecScale(stickl.compos, framedelta * 0.5)); + plrpos = VecAdd(plrpos, VecScale(stickl.compos, framedelta * 500.0)); plrpos.x = pfmod(plrpos.x + hplrSz, rendSize.w + plrSz) - hplrSz; plrpos.y = pfmod(plrpos.y + hplrSz, rendSize.h + plrSz) - hplrSz;