Splinter1991

Members
  • Content count

    1
  • Joined

  • Last visited

Community Reputation

101 Neutral

About Splinter1991

  • Rank
    Newbie
  1. my code:     #include "DarkGDK.h" #include "Box2D/Box2D.h" #include <time.h> float face1X,face1Y, face2X,face2Y,a; bool Click = false;     char SCREEN_VALUE[50] = ""; void DarkGDK ( void ) {     dbSetWindowTitle("Phy");     dbSyncOn   ( );     dbSyncRate ( 60 );     dbBackdropOn();     b2Vec2 gravity(0.0f,50.0f);     bool doSleep = false;     b2World world(gravity);          b2BodyDef groundBodyDef;     groundBodyDef.position.Set(0.0f,600.0f);     b2Body* groundBody = world.CreateBody(&groundBodyDef);     b2PolygonShape groundBox;     groundBox.SetAsBox(600.0f, 10.0f);     groundBody->CreateFixture(&groundBox, 0.0f);     //////////////////////////////////////////////////////////     b2BodyDef myBodyDef;     myBodyDef.type = b2_dynamicBody;//this will be a dynamic body   myBodyDef.position.Set(200, 20); //set the starting position   myBodyDef.angle = 0; //set the starting angle     b2Body* dynamicBody = world.CreateBody(&myBodyDef);   b2PolygonShape boxShape;   boxShape.SetAsBox(50,50);     b2FixtureDef boxFixtureDef;   boxFixtureDef.shape = &boxShape;   boxFixtureDef.density = 10;   boxFixtureDef.friction = 1.3;   dynamicBody->CreateFixture(&boxFixtureDef);     // next             b2BodyDef bodyDef1;     bodyDef1.type = b2_dynamicBody;     bodyDef1.position.Set(260.0f, 100.0f);     b2Body* body1 = world.CreateBody(&bodyDef1);     b2PolygonShape dynamicBox1;     dynamicBox1.SetAsBox(50.0f, 50.0f);     b2FixtureDef fixtureDef1;     fixtureDef1.shape = &dynamicBox1;     fixtureDef1.density = 10;     fixtureDef1.friction = 1.3f;     body1->CreateFixture(&fixtureDef1);     ///////////////////////////////     float32 timeStep = 1.0f / 60.0f;     int32 velocityIterations = 6;     int32 positionIterations = 2;     dbSetDisplayMode(700,700,32);     dbLoadImage ("file\\back.png",1);     dbLoadImage ("file\\1.png",2);             dbDrawSpritesFirst();     while ( LoopGDK ( ) )     {              world.Step(timeStep, velocityIterations, positionIterations);     b2Vec2 position = dynamicBody->GetPosition();     float32 angle = dynamicBody->GetAngle();     b2Vec2 position1 = body1->GetPosition();     float32 angle1 = body1->GetAngle();          face1X = position.x;     face1Y = position.y;     face2X = position1.x;     face2Y = position1.y;             strcpy(SCREEN_VALUE," debug: ");         strcat(SCREEN_VALUE,dbStr(99));         dbText(dbScreenWidth()-705,10,SCREEN_VALUE );     dbSprite(1,0,0,1);//back     dbSprite(2,face1X,face1Y,2);//face            dbRotateSprite(2,angle);     dbSprite(3,face2X,face2Y,2);//face         dbRotateSprite(3,angle1);         position1.x = dbMouseX();         position1.y = dbMouseY();             if(dbMouseClick()==1&&!Click)         {             Click = true;             body1->SetTransform(body1->GetPosition(),a+=1);             }         if(dbMouseClick()==2&&!Click)         {             Click = true;             body1->SetTransform(position1,body1->GetAngle());             }             if( dbMouseClick() != 1 && Click )             {                 Click = false;             }         dbSync();             }     return;     }   sry for mess in code... but as long as i can read it it's ok... i create 2 body one on other and slightly to left that it rotate but object only slide from object and not rotating... and if i change angle 45 degrees and when object hit ground it's still stand on edge 45 degrees rotated   Any ideas?