In Demos/Plink.c, I changed this code:
Code: Select all
// Iterate over all of the bodies and reset the ones that have fallen offscreen.
static void
eachBody(cpBody *body, void *unused)
{
if(body->p.y < -260 || fabsf(body->p.x) > 340){
cpFloat x = rand()/(cpFloat)RAND_MAX*640 - 320;
body->p = cpv(x, 260);
}
}
Code: Select all
// Delete the bodies which have fallen off-screen
static void
eachBody(cpBody *body, void *unused)
{
if(body->p.y < -260 ){
cpBodyFree(body);
}
}
Is there something else I need to do to delete bodies?