objects do not collide correctly SDL and C++

Official forum for the Chipmunk2D Physics Library.
Post Reply
unpardo
Posts: 1
Joined: Tue Jul 21, 2009 9:07 am
Contact:

objects do not collide correctly SDL and C++

Post by unpardo »

I am doing a program with sdl and chipmunk

the basic problem is that the objets dont collide

start a chipmunk and add callback function , the callback is called but the collision is ignored
the init

Code: Select all

	//chipmunk init
	cpInitChipmunk();
	cpSpace * space =cpSpaceNew();
	//gravity
	space->gravity=cpv(0,-100);
the callback

Code: Select all

static int collFunc(cpShape *a, cpShape *b, cpContact *contacts, int numContacts, cpFloat normal_coef, void *data)
{
	printf("collision %d",numContacts);
	fflush(stdout);
	return 1;
}
return true but ojects dont collide :roll:

basic floor

Code: Select all

	//make the floor
	body=cpBodyNew(1000.0, 1000.1);
	shape=cpSegmentShapeNew(body, cpv(0,0), cpv(WINDOW_WIDTH,0), 2.0f);
	shape->e = 1.0; shape->u = 1.0;
	cpSpaceAddStaticShape(space, shape);
in the main loop every frame i do cpSpaceStep(space, 1/50.0);

im working under debian and c++

y attach the source ,executable and script to compile

to compile is needed sdl and sdl image library
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 10 guests