Sync physics properties
This commit is contained in:
parent
8e0c4948a6
commit
a613e19ffa
|
@ -728,6 +728,17 @@ duk_ret_t duk_cmd(duk_context *duk) {
|
||||||
vect2duk(go2world(id2go(duk_to_int(duk,1)),duk2vec2(duk,2)));
|
vect2duk(go2world(id2go(duk_to_int(duk,1)),duk2vec2(duk,2)));
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
case 72:
|
||||||
|
vect2duk(cpSpaceGetGravity(space));
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case 73:
|
||||||
|
cpSpaceSetDamping(space, duk_to_number(duk,1));
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case 74:
|
||||||
|
duk_push_number(duk, cpSpaceGetDamping(space));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -872,6 +883,7 @@ duk_ret_t duk_set_body(duk_context *duk) {
|
||||||
int cmd = duk_to_int(duk, 0);
|
int cmd = duk_to_int(duk, 0);
|
||||||
int id = duk_to_int(duk, 1);
|
int id = duk_to_int(duk, 1);
|
||||||
struct gameobject *go = get_gameobject_from_id(id);
|
struct gameobject *go = get_gameobject_from_id(id);
|
||||||
|
if (!go) return 0;
|
||||||
|
|
||||||
/* TODO: Possible that reindexing shapes only needs done for static shapes? */
|
/* TODO: Possible that reindexing shapes only needs done for static shapes? */
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
@ -915,6 +927,14 @@ duk_ret_t duk_set_body(duk_context *duk) {
|
||||||
cpBodySetVelocity(go->body, duk2vec2(duk, 2));
|
cpBodySetVelocity(go->body, duk2vec2(duk, 2));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
go->e = fmax(duk_to_number(duk,2), 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 11:
|
||||||
|
go->f = fmax(duk_to_number(duk,2),0);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cpSpaceReindexShapesForBody(space, go->body);
|
cpSpaceReindexShapesForBody(space, go->body);
|
||||||
|
@ -1095,6 +1115,8 @@ duk_ret_t duk_cmd_poly2d(duk_context *duk)
|
||||||
int cmd = duk_to_int(duk,0);
|
int cmd = duk_to_int(duk,0);
|
||||||
struct phys2d_poly *poly = duk_to_pointer(duk,1);
|
struct phys2d_poly *poly = duk_to_pointer(duk,1);
|
||||||
|
|
||||||
|
if (!poly) return 0;
|
||||||
|
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case 0:
|
case 0:
|
||||||
phys2d_poly_setverts(poly, duk2cpvec2arr(duk,2));
|
phys2d_poly_setverts(poly, duk2cpvec2arr(duk,2));
|
||||||
|
@ -1137,6 +1159,8 @@ duk_ret_t duk_cmd_edge2d(duk_context *duk)
|
||||||
int cmd = duk_to_int(duk, 0);
|
int cmd = duk_to_int(duk, 0);
|
||||||
struct phys2d_edge *edge = duk_to_pointer(duk, 1);
|
struct phys2d_edge *edge = duk_to_pointer(duk, 1);
|
||||||
|
|
||||||
|
if (!edge) return 0;
|
||||||
|
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case 0:
|
case 0:
|
||||||
phys2d_edge_clearverts(edge);
|
phys2d_edge_clearverts(edge);
|
||||||
|
|
Loading…
Reference in a new issue