From 186c83659c479a9284e2b5c8a348ce34b865d27c Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sun, 26 Feb 2023 16:24:21 +0000 Subject: [PATCH] boundingbox functions --- source/engine/ffi.c | 24 +++++++++++++++++++++++- source/engine/gameobject.c | 4 +--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/source/engine/ffi.c b/source/engine/ffi.c index 7665532..2faa721 100644 --- a/source/engine/ffi.c +++ b/source/engine/ffi.c @@ -195,10 +195,19 @@ duk_ret_t duk_nuke(duk_context *duk) float editnum; int editint; char textbox[130]; + struct nk_rect rect = nk_rect(0,0,0,0); switch(cmd) { case 0: - nuke_begin_win(duk_to_string(duk, 1)); + duk_get_prop_string(duk, 2, "x"); + rect.x = duk_to_number(duk,-1); + duk_get_prop_string(duk, 2, "y"); + rect.y = duk_to_number(duk,-1); + duk_get_prop_string(duk,2,"w"); + rect.w = duk_to_number(duk,-1); + duk_get_prop_string(duk,2,"h"); + rect.h = duk_to_number(duk,-1); + nuke_begin(duk_to_string(duk, 1),rect, NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_SCALABLE | NK_WINDOW_TITLE); break; case 1: @@ -244,6 +253,19 @@ duk_ret_t duk_nuke(duk_context *duk) nuke_radio_btn(duk_to_string(duk,1), &editint, duk_to_int(duk, 3)); duk_push_int(duk, editint); return 1; + + case 10: + rect = nuke_win_get_bounds(); + duk_push_object(duk); + duk_push_number(duk, rect.x); + duk_put_prop_string(duk, -2, "x"); + duk_push_number(duk,rect.y); + duk_put_prop_string(duk, -2, "y"); + duk_push_number(duk,rect.w); + duk_put_prop_string(duk,-2,"w"); + duk_push_number(duk,rect.h); + duk_put_prop_string(duk,-2,"h"); + return 1; } return 0; diff --git a/source/engine/gameobject.c b/source/engine/gameobject.c index d8fbd10..0e8719e 100644 --- a/source/engine/gameobject.c +++ b/source/engine/gameobject.c @@ -95,7 +95,7 @@ void go_shape_apply(cpBody *body, cpShape *shape, struct gameobject *go) { cpShapeSetFriction(shape, go->f); cpShapeSetElasticity(shape, go->e); - cpShapeSetSensor(shape, go->sensor); +// cpShapeSetSensor(shape, go->sensor); cpShapeSetCollisionType(shape, go2id(go)); float moment = cpBodyGetMoment(go->body); @@ -117,8 +117,6 @@ void gameobject_apply(struct gameobject *go) cpBodyEachShape(go->body, go_shape_apply, go); if (go->bodytype == CP_BODY_TYPE_DYNAMIC) cpBodySetMass(go->body, go->mass); - - } static void gameobject_setpickcolor(struct gameobject *go)