write code for a timing

This commit is contained in:
2025-06-24 22:43:46 +02:00
parent a7d5f1bb2a
commit 94cfbdcaad
2 changed files with 51 additions and 0 deletions

12
src/game/time.h Normal file
View File

@@ -0,0 +1,12 @@
#pragma once
#include <sys/cdefs.h>
#include <time.h>
/* gets the current time in milliseconds */
time_t time_pull(void);
/* Polls the time whether a given timeout has passed, comparing against `curr` as the current time.
* if `curr` ≥ `*proj`, `curr` + `delta` is written to `*proj`. `1` is returned.
* otherwise, we just return `0`. */
__nonnull((3)) int time_poll(time_t curr, time_t delta, time_t* restrict proj);