From 7eca07c7d149c8dea058a9286e5f34db250361d8 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sat, 26 Apr 2025 09:42:23 -0500 Subject: [PATCH] fix actor delay time always being 0 --- source/prosperon.c | 5 +++-- tests/camera.js | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/prosperon.c b/source/prosperon.c index a1917292..82c9f522 100644 --- a/source/prosperon.c +++ b/source/prosperon.c @@ -523,7 +523,8 @@ JSValue js_actor_delay(JSContext *js, JSValue self, int argc, JSValue *argv) prosperon_rt *actor = JS_GetContextOpaque(js); double seconds; JS_ToFloat64(js, &seconds, argv[1]); - Uint32 id = SDL_AddTimerNS(SDL_SECONDS_TO_NS(seconds), actor_timer_cb, actor); + Uint64 ns = seconds * SDL_NS_PER_SECOND; + Uint32 id = SDL_AddTimerNS(ns, actor_timer_cb, actor); SDL_LockMutex(actor->msg_mutex); JSValue cb = JS_DupValue(js, argv[0]); @@ -534,7 +535,7 @@ JSValue js_actor_delay(JSContext *js, JSValue self, int argc, JSValue *argv) } SDL_UnlockMutex(actor->msg_mutex); - return JS_UNDEFINED; + return JS_NewUint32(js, id); } JSValue js_actor_removetimer(JSContext *js, JSValue self, int argc, JSValue *argv) diff --git a/tests/camera.js b/tests/camera.js index 7ca3b362..18e70d04 100644 --- a/tests/camera.js +++ b/tests/camera.js @@ -36,11 +36,17 @@ var hudcam = { } var angle = 0 +var pos = [0,0,0] +var s = 0 +var f = 0 function loop() { - angle += 1/240 + pos.x += 1 + camera.transform.pos = pos render.clear(Color.red) - render.camera(hudcam) + render.camera(camera) + draw.image("button_grey", [0,0]) + /* draw.line([[0,0],[100,50]]) draw.point([100,100]) draw.circle([200,200],40) @@ -52,8 +58,8 @@ function loop() draw.rectangle({x:100, y:60, width:200, height:60}, {radius: 20, thickness:-3}) draw.rectangle({x:350, y:60, width:200, height:120}, {radius:10,thickness:3}) */ - draw.image("diddy", [0,0], angle, [0,0]) - draw.image("panel_beige", [300,300]) + render.camera(hudcam) + draw.image("button_grey", [0,0]) render.present() $_.delay(loop, 1/60) }