Bodies refuse to accept force

Official forum for the Chipmunk2D Physics Library.
Post Reply
NeXEkho
Posts: 1
Joined: Fri Jun 19, 2009 8:39 am
Contact:

Bodies refuse to accept force

Post by NeXEkho »

I am trying to implement Chipmunk into my procedural C project. I've experience with Box2D and would use that except it's written in C++. I've four examples and tutorials on hand and as far as I can see amoungst the mess of irrelevant (to the physics) API calls I've remembered everything. Problem is, when I run my code, the bodies go where I tell them and then stay there as if I've run a nail through them. Gravity seems not to apply and any impulses or forces I add don't register and aren't present in the body's variables.

Console output:
(unnecessary repetition removed)

Code: Select all

HADOUKEN!

--------------------------------------

Booting...

        Game
        GLFW
        Window opened
        Audio ( ALUT )
        Media engine
        Font
        Interface
        Gamepads
        Physics (Chipmunk Game Dynamics)
        DONE

--------------------------------------

Arena made
step
step
step
step
step
Pos: 151.000000, -32.000000 Angle: 0.000000 Vels: 0.000000, 0.000000
step
Pos: 151.000000, -32.000000 Angle: 0.000000 Vels: 0.000000, 0.000000
step
Pos: 151.000000, -32.000000 Angle: 0.000000 Vels: 0.000000, 0.000000
step
Pos: 151.000000, -32.000000 Angle: 0.000000 Vels: 0.000000, 0.000000
step

--------------------------------------

Shutting down...

        Chipmunk slaughtered.
        Pads yanked.
        Interface killed.
        Font unloaded.
        Media engine stopped.
        Audio safely shut down.
        Window closed.
        GLFW safely shut down.
        Game killed.

Process returned 0 (0x0)   execution time : 6.734 s
Press any key to continue.
Code for initialising Chipmunk:

Code: Select all

    cpInitChipmunk();

    printf( "Physics (Chipmunk Game Dynamics)\n\t" );
Code for making space:

Code: Select all

            cpsArena = cpSpaceNew();

            cpsArena->gravity = cpv( 0, -100 );

            printf( "Arena made\n" );
Code for making objects:

Code: Select all

tsMyInstance->cpbBody = cpBodyNew(100.0, cpMomentForCircle(100.0,20.0,0.0f, cpvzero));

// Set the initial position

tsMyInstance->cpbBody->p = cpv(si16MouseX,si16MouseY);

// Add the body to the space

cpSpaceAddBody(cpsArena, tsMyInstance->cpbBody);

// Create our shape associated with the ball's body

cpShape * cpsCircle = cpCircleShapeNew(tsMyInstance->cpbBody, 20.0, cpvzero);

cpsCircle->e = 0.5; // Elasticity

cpsCircle->u = 0.8; // Friction

// Add the shape to out space

cpSpaceAddShape(cpsArena, cpsCircle);
Code for advancing frame:

Code: Select all

            printf( "step\n" );

                cpSpaceStep(cpsArena, 1.0/60.0);
Does anything jump out as missing or incorrect? Much of it is adapted from tutorials which were packed with typos.

The demos work really well after some slight adjustments are made to compensate for a lack of function overloading in my GCC. So it's not outside of my code, whatever it is.
Post Reply

Who is online

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