fix actor delay time always being 0
This commit is contained in:
@@ -523,7 +523,8 @@ JSValue js_actor_delay(JSContext *js, JSValue self, int argc, JSValue *argv)
|
|||||||
prosperon_rt *actor = JS_GetContextOpaque(js);
|
prosperon_rt *actor = JS_GetContextOpaque(js);
|
||||||
double seconds;
|
double seconds;
|
||||||
JS_ToFloat64(js, &seconds, argv[1]);
|
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);
|
SDL_LockMutex(actor->msg_mutex);
|
||||||
JSValue cb = JS_DupValue(js, argv[0]);
|
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);
|
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)
|
JSValue js_actor_removetimer(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||||
|
|||||||
@@ -36,11 +36,17 @@ var hudcam = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var angle = 0
|
var angle = 0
|
||||||
|
var pos = [0,0,0]
|
||||||
|
var s = 0
|
||||||
|
var f = 0
|
||||||
function loop()
|
function loop()
|
||||||
{
|
{
|
||||||
angle += 1/240
|
pos.x += 1
|
||||||
|
camera.transform.pos = pos
|
||||||
render.clear(Color.red)
|
render.clear(Color.red)
|
||||||
render.camera(hudcam)
|
render.camera(camera)
|
||||||
|
draw.image("button_grey", [0,0])
|
||||||
|
|
||||||
/* draw.line([[0,0],[100,50]])
|
/* draw.line([[0,0],[100,50]])
|
||||||
draw.point([100,100])
|
draw.point([100,100])
|
||||||
draw.circle([200,200],40)
|
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: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.rectangle({x:350, y:60, width:200, height:120}, {radius:10,thickness:3})
|
||||||
*/
|
*/
|
||||||
draw.image("diddy", [0,0], angle, [0,0])
|
render.camera(hudcam)
|
||||||
draw.image("panel_beige", [300,300])
|
draw.image("button_grey", [0,0])
|
||||||
render.present()
|
render.present()
|
||||||
$_.delay(loop, 1/60)
|
$_.delay(loop, 1/60)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user