From f805bf3f9232605861a72daa362e49541fd47fa8 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Thu, 20 Feb 2025 14:04:04 +0300 Subject: [PATCH] add interval from timer_elapse_seconds() result, add timers to twn_api.json --- include/twn_util.h | 2 +- share/twn_api.json | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/twn_util.h b/include/twn_util.h index 164231f..f21494f 100644 --- a/include/twn_util.h +++ b/include/twn_util.h @@ -53,7 +53,7 @@ TWN_API bool rect_intersects(Rect a, Rect b); TWN_API float timer_tick_seconds(float seconds_left); typedef struct TimerElapseSecondsResult { - bool elapsed; float seconds_left; + float seconds_left; float interval; bool elapsed; } TimerElapseSecondsResult; TWN_API TimerElapseSecondsResult timer_elapse_seconds(float seconds_left, float interval); diff --git a/share/twn_api.json b/share/twn_api.json index 5ea4b2f..186cca4 100644 --- a/share/twn_api.json +++ b/share/twn_api.json @@ -264,6 +264,34 @@ ] }, + "timer_tick_seconds": { + "module": "util", + "symbol": "tick_seconds", + "header": "twn_util.h", + "params": [ + { "name": "seconds_left", "type": "float" } + ], + "return": "float" + }, + + "timer_elapse_seconds": { + "module": "util", + "symbol": "elapse_seconds", + "header": "twn_util.h", + "params": [ + { "name": "seconds_left", "type": "float" }, + { "name": "interval", "type": "float" } + ], + "return": { + "fields": [ + { "name": "seconds_left", "type": "float" }, + { "name": "interval", "type": "float" }, + { "name": "elapsed", "type": "bool" } + ], + "c_type": "TimerElapseSecondsResult" + } + }, + "log_vec2": { "module": "util", "symbol": "log_vec2",