I have a body with infinite inertia. It falls to the ground normally, but if you throw it up, it passes through the object.
Code: Select all
struct PlayerObj *createPlayer(cpSpace *area, cpFloat mass, cpFloat x, cpFloat y, cpFloat w, cpFloat h)
{
struct PlayerObj *obj = malloc(sizeof(struct PlayerObj));
obj->w = w;
obj->h = h;
obj->body = cpSpaceAddBody(area, cpBodyNew(mass, cpMomentForBox(mass, w, h)));
cpBodySetPos(obj->body, cpv(x, y));
obj->shape = cpSpaceAddShape(area, cpBoxShapeNew(obj->body, w, h));
return obj;
}
struct BoxObj *createBox(cpSpace *area, cpFloat x, cpFloat y, cpFloat w, cpFloat h)
{
struct BoxObj *obj=malloc(sizeof(struct BoxObj));
obj->x=x;
obj->y=y;
obj->w=w;
obj->h=h;
cpVect vect[4];
vect[0] = cpv(x, y);
vect[1] = cpv(x, y+h);
vect[2] = cpv(x+w, y+h);
vect[3] = cpv(x+w, y);
obj->shape = cpPolyShapeNew(area->staticBody, 4, vect, cpvzero);
cpSpaceAddStaticShape(area, obj->shape);
return obj;
}
Code: Select all
cpBodyApplyImpulse(Player->body, cpv(0.0, -160.0), cpvzero);