I use devc++, mingw and allegro.
all source is here:
main:
Code:
b2Vec2 gravity(0.0f,-10.0f);
bool doSleep=true;
b2World world(gravity, doSleep);
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0.0f, -10.0f);
b2Body * groundBody = world.CreateBody(&groundBodyDef);
b2PolygonShape groundBox;
groundBox.SetAsBox(50.0f, 10.0f);
groundBody->CreateFixture(&groundBox, 0.0f);
textprintf_ex(screen,font,40,140,0xff0000,-1,"1");
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(0.0f, 4.0f);
b2Body* body = world.CreateBody(&bodyDef);
textprintf_ex(screen,font,40,150,0xff0000,-1,"2");
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(1.0f, 1.0f);
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.3f;
textprintf_ex(screen,font,40,160,0xff0000,-1,"3");
body->CreateFixture(&dynamicBox,1.0f);
textprintf_ex(screen,font,40,170,0xff0000,-1,"4");
float32 timeStep = 1.0f / 60.0f;
textprintf_ex(screen,font,40,180,0xff0000,-1,"5");
int32 velocityIterations = 6;
int32 positionIterations = 2;
while (!key[KEY_ESC])
{
world.Step(timeStep, velocityIterations, positionIterations);
b2Vec2 position = body->GetPosition();
float32 angle = body->GetAngle();
clear_to_color(screen,0x0);
textprintf_ex(screen,font,40,140,0xff0000,-1,"%f %f %f\n",position.x, position.y, angle);
}