refined controls
This commit is contained in:
parent
f4d08bcacb
commit
cdff383a7a
|
@ -85,13 +85,19 @@ void querylistbodies(cpBody *body, void *data)
|
||||||
|
|
||||||
int *phys2d_query_box(cpVect pos, cpVect wh)
|
int *phys2d_query_box(cpVect pos, cpVect wh)
|
||||||
{
|
{
|
||||||
cpBB bbox = cpBBNewForExtents(pos, wh.x, wh.y);
|
cpShape *box = cpBoxShapeNew(NULL, wh.x, wh.y, 0.f);
|
||||||
cpShape *box = cpBoxShapeNew2(NULL, bbox, 0.f);
|
cpTransform T = {0};
|
||||||
|
T.a = 1;
|
||||||
|
T.d = 1;
|
||||||
|
T.tx = pos.x;
|
||||||
|
T.ty = pos.y;
|
||||||
|
cpShapeUpdate(box, T);
|
||||||
|
|
||||||
|
cpBB bbox = cpShapeGetBB(box);
|
||||||
|
|
||||||
if (qhits) arrfree(qhits);
|
if (qhits) arrfree(qhits);
|
||||||
cpSpaceShapeQuery(space, box, querylist, NULL);
|
|
||||||
|
|
||||||
YughInfo("FInished query.");
|
cpSpaceShapeQuery(space, box, querylist, NULL);
|
||||||
|
|
||||||
cpSpaceEachBody(space, querylistbodies, &bbox);
|
cpSpaceEachBody(space, querylistbodies, &bbox);
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,11 @@
|
||||||
(byte & 0x02 ? '1' : '0'), \
|
(byte & 0x02 ? '1' : '0'), \
|
||||||
(byte & 0x01 ? '1' : '0')
|
(byte & 0x01 ? '1' : '0')
|
||||||
|
|
||||||
|
struct gameobject *duk2go(duk_context *duk, int p)
|
||||||
|
{
|
||||||
|
return id2go(duk_to_int(duk, p));
|
||||||
|
}
|
||||||
|
|
||||||
struct color duk2color(duk_context *duk, int p)
|
struct color duk2color(duk_context *duk, int p)
|
||||||
{
|
{
|
||||||
struct color color;
|
struct color color;
|
||||||
|
@ -512,6 +517,27 @@ duk_ret_t duk_cmd(duk_context *duk) {
|
||||||
draw_box(duk2vec2(duk, 1), duk2vec2(duk, 2));
|
draw_box(duk2vec2(duk, 1), duk2vec2(duk, 2));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case 54:
|
||||||
|
gameobject_apply(id2go(duk_to_int(duk, 1)));
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case 55:
|
||||||
|
duk2go(duk, 1)->flipx = duk_to_boolean(duk, 2) ? -1 : 1;
|
||||||
|
gameobject_apply(duk2go(duk, 1));
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case 56:
|
||||||
|
duk2go(duk, 1)->flipy = duk_to_boolean(duk, 2) ? -1 : 1;
|
||||||
|
gameobject_apply(duk2go(duk, 1));
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case 57:
|
||||||
|
duk_push_boolean(duk, duk2go(duk, 1)->flipx == -1 ? 1 : 0);
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case 58:
|
||||||
|
duk_push_boolean(duk, duk2go(duk, 1)->flipy == -1 ? 1 : 0);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -616,8 +642,8 @@ duk_ret_t duk_make_gameobject(duk_context *duk) {
|
||||||
go->mass = duk_to_number(duk, 2);
|
go->mass = duk_to_number(duk, 2);
|
||||||
go->f = duk_to_number(duk, 3);
|
go->f = duk_to_number(duk, 3);
|
||||||
go->e = duk_to_number(duk, 4);
|
go->e = duk_to_number(duk, 4);
|
||||||
go->flipx = duk_to_boolean(duk, 5) ? -1 : 1;
|
go->flipx = 1.f;
|
||||||
go->flipy = duk_to_boolean(duk, 6) ? -1 : 1;
|
go->flipy = 1.f;
|
||||||
|
|
||||||
gameobject_apply(go);
|
gameobject_apply(go);
|
||||||
|
|
||||||
|
@ -663,7 +689,7 @@ duk_ret_t duk_set_body(duk_context *duk) {
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
cpBodyApplyImpulseAtWorldPoint(go->body, duk2vec2(duk, 2), cpBodyGetPosition(go->body));
|
cpBodyApplyImpulseAtWorldPoint(go->body, duk2vec2(duk, 2), cpBodyGetPosition(go->body));
|
||||||
break;
|
return 0;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
go->flipx = duk_to_boolean(duk, 2);
|
go->flipx = duk_to_boolean(duk, 2);
|
||||||
|
|
|
@ -35,8 +35,7 @@ struct gameobject *id2go(int id)
|
||||||
|
|
||||||
int body2id(cpBody *body)
|
int body2id(cpBody *body)
|
||||||
{
|
{
|
||||||
struct gameobject *go = cpBodyGetUserData(body);
|
return cpBodyGetUserData(body);
|
||||||
return id_from_gameobject(go);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int shape2gameobject(cpShape *shape)
|
int shape2gameobject(cpShape *shape)
|
||||||
|
@ -74,6 +73,13 @@ void go_shape_apply(cpBody *body, cpShape *shape, struct gameobject *go)
|
||||||
{
|
{
|
||||||
cpShapeSetFriction(shape, go->f);
|
cpShapeSetFriction(shape, go->f);
|
||||||
cpShapeSetElasticity(shape, go->e);
|
cpShapeSetElasticity(shape, go->e);
|
||||||
|
|
||||||
|
cpTransform T = {0};
|
||||||
|
T.a = go->flipx;
|
||||||
|
T.d = go->flipy;
|
||||||
|
cpShapeUpdate(shape, T);
|
||||||
|
|
||||||
|
if (go->flipx == -1) YughInfo("Flipped one");
|
||||||
// cpShapeSetFilter(shape, go->filter);
|
// cpShapeSetFilter(shape, go->filter);
|
||||||
|
|
||||||
// YughLog("Set filter; %d", go->filter.mask);
|
// YughLog("Set filter; %d", go->filter.mask);
|
||||||
|
@ -123,6 +129,7 @@ int MakeGameobject()
|
||||||
first = id2go(first)->next;
|
first = id2go(first)->next;
|
||||||
*id2go(retid) = go;
|
*id2go(retid) = go;
|
||||||
}
|
}
|
||||||
|
|
||||||
go.filter.group = retid;
|
go.filter.group = retid;
|
||||||
go.filter.mask = CP_ALL_CATEGORIES;
|
go.filter.mask = CP_ALL_CATEGORIES;
|
||||||
go.filter.categories = CP_ALL_CATEGORIES;
|
go.filter.categories = CP_ALL_CATEGORIES;
|
||||||
|
|
|
@ -141,6 +141,14 @@ const char *keyname_extd(int key, int scancode) {
|
||||||
kkey = "escape";
|
kkey = "escape";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GLFW_KEY_DELETE:
|
||||||
|
kkey = "delete";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GLFW_KEY_INSERT:
|
||||||
|
kkey = "insert";
|
||||||
|
break;
|
||||||
|
|
||||||
case GLFW_KEY_TAB:
|
case GLFW_KEY_TAB:
|
||||||
kkey = "tab";
|
kkey = "tab";
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue