This commit is contained in:
2023-01-10 23:23:11 +00:00
parent 3e4edf1ea3
commit 3baec775a8
4 changed files with 119 additions and 12 deletions

View File

@@ -23,12 +23,13 @@ float phys2d_gravity = -50.f;
void phys2d_init()
{
space = cpSpaceNew();
phys2d_set_gravity(0, phys2d_gravity);
cpVect grav = {0, phys2d_gravity};
phys2d_set_gravity(grav);
cpSpaceSetGravity(space, cpv(0, phys2d_gravity));
}
void phys2d_set_gravity(float x, float y) {
cpSpaceSetGravity(space, cpv(x, y));
void phys2d_set_gravity(cpVect v) {
cpSpaceSetGravity(space, v);
}
void phys2d_update(float deltaT)
@@ -36,11 +37,6 @@ void phys2d_update(float deltaT)
cpSpaceStep(space, deltaT);
}
void phys2d_apply()
{
phys2d_set_gravity(0, phys2d_gravity);
}
void phys2d_shape_apply(struct phys2d_shape *shape)
{
cpShapeSetFriction(shape->shape, shape->go->f);