boundingbox functions

This commit is contained in:
John Alanbrook 2023-02-26 16:24:21 +00:00
parent a3428f0d36
commit 186c83659c
2 changed files with 24 additions and 4 deletions

View file

@ -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;

View file

@ -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)