From 2df559aa4c3aa01de32aef62c743f906820b4335 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Tue, 27 Dec 2022 18:52:25 +0000 Subject: [PATCH] Hit params in collider works --- source/engine/2dphysics.c | 1 + source/engine/mrbffi.c | 21 ++++++++++----------- source/engine/script.c | 2 +- source/scripts/engine.scm | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/engine/2dphysics.c b/source/engine/2dphysics.c index 0072d2d..242d1a2 100644 --- a/source/engine/2dphysics.c +++ b/source/engine/2dphysics.c @@ -463,6 +463,7 @@ static cpBool s7_phys_cb_begin(cpArbiter *arb, cpSpace *space, void *data) { struct gameobject *g2 = cpBodyGetUserData(body2); script_call_sym_args(go->cbs->begin, s7_make_integer(s7, g2->editor.id)); + //script_call_sym(go->cbs->begin); return 1; } diff --git a/source/engine/mrbffi.c b/source/engine/mrbffi.c index 7ae34d1..524fa10 100644 --- a/source/engine/mrbffi.c +++ b/source/engine/mrbffi.c @@ -24,8 +24,8 @@ cpVect s7tovec2(s7_scheme *sc, s7_pointer s7vec) { cpVect ret; - ret.x = s7_vector_ref(sc, s7vec, 0); - ret.y = s7_vector_ref(sc, s7vec, 1); + ret.x = s7_real(s7_vector_ref(sc, s7vec, 0)); + ret.y = s7_real(s7_vector_ref(sc, s7vec, 1)); return ret; } @@ -68,23 +68,22 @@ s7_pointer s7_ui_text(s7_scheme *sc, s7_pointer args) { s7_pointer s7_gui_text(s7_scheme *sc, s7_pointer args) { const char *s = s7_string(s7_car(args)); - s7_pointer s7pos = s7_cadr(args); - double pos[2] = { s7_vector_ref(sc, s7pos, 0), s7_vector_ref(sc, s7pos, 1) }; + cpVect pos = s7tovec2(sc, s7_cadr(args)); + float fpos[2] = {pos.x, pos.y}; float size = s7_real(s7_caddr(args)); const float white[3] = {1.f, 1.f, 1.f}; - renderText(s, pos, size, white, 200); + renderText(s, fpos, size, white, 200); return s7_car(args); } s7_pointer s7_gui_img(s7_scheme *sc, s7_pointer args) { const char *img = s7_string(s7_car(args)); - s7_pointer s7pos = s7_cadr(args); - double pos[2] = { s7_vector_ref(sc, s7pos, 0), s7_vector_ref(sc, s7pos, 1) }; + cpVect pos = s7tovec2(sc, s7_cadr(args)); - gui_draw_img(img, pos[0], pos[1]); + gui_draw_img(img, pos.x, pos.y); return args; } @@ -324,7 +323,7 @@ s7_pointer s7_set_body(s7_scheme *sc, s7_pointer args) { break; case 2: - cpBodySetPosition(go, s7tovec2(sc, s7_caddr(args))); + cpBodySetPosition(go->body, s7tovec2(sc, s7_caddr(args))); break; case 3: @@ -402,8 +401,8 @@ void ffi_load() { S7_FUNC(ui_text, 2); S7_FUNC(ui_rendertext, 3); - S7_FUNC(gui_text, 4); - S7_FUNC(gui_img, 3); + S7_FUNC(gui_text, 3); + S7_FUNC(gui_img, 2); S7_FUNC(gen_cmd, 2); S7_FUNC(sys_cmd, 1); diff --git a/source/engine/script.c b/source/engine/script.c index b1b344b..24c374f 100644 --- a/source/engine/script.c +++ b/source/engine/script.c @@ -97,7 +97,7 @@ void script_call_sym(s7_pointer sym) void script_call_sym_args(s7_pointer sym, s7_pointer args) { - s7_call(s7, sym, args); + s7_call(s7, sym, s7_cons(s7, args, s7_nil(s7))); } int script_has_sym(s7_pointer sym) { diff --git a/source/scripts/engine.scm b/source/scripts/engine.scm index a848a5d..c0af8c5 100644 --- a/source/scripts/engine.scm +++ b/source/scripts/engine.scm @@ -73,7 +73,7 @@ (define-macro (gui . expr) `(registertype gui - (let ((x 0) (y 0)) ,@expr))) + (let ((pos #(0 0))) ,@expr))) (define-macro (while condition . body) (let ((loop (gensym)))