This commit is contained in:
2022-08-29 03:34:33 +00:00
parent c56e2841b6
commit 81986d6bad
8 changed files with 113 additions and 22 deletions

View File

@@ -42,6 +42,11 @@ void init_phys2dshape(struct phys2d_shape *shape, struct mGameObject *go)
phys2d_shape_apply(shape);
}
void phys2d_shape_del(struct phys2d_shape *shape)
{
cpSpaceRemoveShape(space, shape->shape);
}
struct phys2d_circle *Make2DCircle(struct mGameObject *go)
{
struct phys2d_circle *new = malloc(sizeof(struct phys2d_circle));
@@ -61,6 +66,11 @@ void phys2d_circleinit(struct phys2d_circle *circle, struct mGameObject *go)
init_phys2dshape(&circle->shape, go);
}
void phys2d_circledel(struct phys2d_circle *c)
{
phys2d_shape_del(&c->shape);
}
void circle_gui(struct phys2d_circle *circle)
{
nk_property_float(ctx, "Radius", 1.f, &circle->radius, 10000.f, 1.f, 1.f);
@@ -98,6 +108,11 @@ void phys2d_seginit(struct phys2d_segment *seg, struct mGameObject *go)
init_phys2dshape(&seg->shape, go);
}
void phys2d_segdel(struct phys2d_segment *seg)
{
phys2d_shape_del(&seg->shape);
}
void segment_gui(struct phys2d_segment *seg)
{
nk_property_float2(ctx, "a", 0.f, seg->a, 1.f, 0.01f, 0.01f);
@@ -130,6 +145,11 @@ void phys2d_boxinit(struct phys2d_box *box, struct mGameObject *go)
phys2d_applybox(box);
}
void phys2d_boxdel(struct phys2d_box *box)
{
phys2d_shape_del(&box->shape);
}
void box_gui(struct phys2d_box *box)
{
nk_property_float(ctx, "Width", 0.f, &box->w, 1000.f, 1.f, 1.f);
@@ -164,6 +184,11 @@ void phys2d_polyinit(struct phys2d_poly *poly, struct mGameObject *go)
phys2d_applypoly(poly);
}
void phys2d_polydel(struct phys2d_poly *poly)
{
phys2d_shape_del(&poly->shape);
}
void phys2d_polyaddvert(struct phys2d_poly *poly)
{
poly->n++;
@@ -215,6 +240,11 @@ void phys2d_edgeinit(struct phys2d_edge *edge, struct mGameObject *go)
phys2d_applyedge(edge);
}
void phys2d_edgedel(struct phys2d_edge *edge)
{
phys2d_shape_del(&edge->shape);
}
void phys2d_edgeshapeapply(struct phys2d_shape *mshape, cpShape * shape)
{
cpShapeSetFriction(shape, mshape->go->f);