So far, I've modified one of the demo's in B2D, the simple pendulum. I've duplicated it, and now I have two pendulums. Spaced apart evenly. The first problem I have, is that if I try to access Body->position at all, my game crashes. I'm not sure why that's happening... The second problem I'm having is logical, I guess. I can't determine how I should switch a weight with the player, depending on which trapeze he's on.
The joints both have a "weight" on the end, because as far as I know, the joint has to be connected to two bodies. Can you detach one body and have the joint still working, can you detach a body from a joint at ALL?
I think that's all the questions I have right now, but I hope someone can help. I'd really like to become familiar with Box2D.
BTW, I've pasted the code to initialize the joints and bodies. Kinda long, hope this is ok.

Code: Select all
void Demo1()
{
int length = 175;
// FLOOR
Body* b1 = new Body();
b1->Set( hgeVector( SCREEN_WIDTH - 1, 30 ), FLT_MAX );
b1->position = hgeVector( SCREEN_WIDTH / 2, SCREEN_HEIGHT - 15 );
b1->friction = 0.2f;
world.Add( b1 );
bodies.push_back( b1 );
// FIRST BASE
Body* b2 = new Body();
b2->Set( hgeVector( 50, 10 ), FLT_MAX );
b2->position = hgeVector( 200, SCREEN_HEIGHT - 35 );
//b2->friction = 0.2f;
world.Add( b2 );
bodies.push_back( b2 );
// SECOND BASE
Body* b3 = new Body();
b3->Set( hgeVector( 50, 10 ), FLT_MAX );
b3->position = hgeVector( SCREEN_WIDTH - 200, SCREEN_HEIGHT - 35 );
//b3->friction = 0.2f;
world.Add( b3 );
bodies.push_back( b3 );
// FIRST WEIGHT
Body* b4 = new Body();
b4->Set( hgeVector( 20, 20 ), 20 );
b4->friction = 0.5f;
b4->position = hgeVector( 200 + length, 200 );
b4->rotation = 0.0f;
world.Add( b4 );
bodies.push_back( b4 );
// SECOND WEIGHT
Body* b5 = new Body();
b5->Set( hgeVector( 20, 20 ), 20 );
b5->friction = 0.5f;
b5->position = hgeVector( SCREEN_WIDTH - 200 + -length, 200 );
b5->rotation = 0.0f;
world.Add( b5 );
bodies.push_back( b5 );
// PLAYER
Body* player = new Body();
player->Set( hgeVector( 30, 75 ), 100 );
player->position = hgeVector( SCREEN_WIDTH / 2, 0 );
player->friction = 0.2f;
player->rotation = 0.0f;
world.Add( player );
bodies.push_back( player );
// FIRST TRAPEZE
Joint *j1 = new Joint();
j1->Set( b2, b4, hgeVector( 200, 200 ) );
world.Add( j1 );
joints.push_back( j1 );
// SECOND TRAPEZE
Joint *j2 = new Joint();
j2->Set( b3, b5, hgeVector( SCREEN_WIDTH - 200, 200 ) );
world.Add( j2 );
joints.push_back( j2 );
}