Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

MARS_999

Member Since 06 Mar 2001
Offline Last Active Yesterday, 06:53 AM
-----

Posts I've Made

In Topic: Big G the same at various screen sizes....

18 April 2013 - 05:05 PM

b2Vec2 position = body->GetPosition();

 

I get the positions form Box2d so the coordinates should be done in physics terms...

 

then I use that variable to draw the object


In Topic: Big G the same at various screen sizes....

17 April 2013 - 05:07 PM

NX::App* p = NX::App::Get();
    
    b2BodyDef bodyDef;
    bodyDef.type = b2_dynamicBody;
    bodyDef.position.Set(posX, posY);

    KillBody();
    
    body = p->GetWorld()->CreateBody(&bodyDef);

    b2PolygonShape dynamicBox;
    dynamicBox.SetAsBox(sizeX, sizeY);

    b2FixtureDef fixtureDef;
    fixtureDef.shape = &dynamicBox;

    // Set the box density to be non-zero, so it will be dynamic.
    fixtureDef.density = 1.0f;

    // Override the default friction.
    fixtureDef.friction = 0.3f;

    // Add the shape to the body.
    body->CreateFixture(&fixtureDef);

    body->SetUserData(this);

In Topic: Big G the same at various screen sizes....

17 April 2013 - 08:25 AM

I will post it tonight....

In Topic: Big G the same at various screen sizes....

17 April 2013 - 01:35 AM

Sigh, I guess I am just to dense to make this happen people... but I have tried and this is what I am using now. LIke I said when I change the screen resolution from 1024x768 to 1920x1080 the objects take to long to move as the magnetism is weakened. I am not using the screen size in this code, I am using box2D GetWorldCenter() and that is it....

 

 

 

for(b2Body* b1 = world->GetBodyList(); b1; b1 = b1->GetNext())    
    {
        void* data1 = b1->GetUserData();
        b2Vec2 pi = b1->GetWorldCenter();
        float mi = b1->GetMass();
        for(b2Body* b2 =world->GetBodyList(); b2; b2 = b2->GetNext())
        {
            void* data2 = b2->GetUserData();
            if(b1 == b2 || !data1 || !data2 )
                continue;                
            b2Vec2 pk = b2->GetWorldCenter();
            float mk = b2->GetMass();
            b2Vec2 delta = pk - pi;
            float r = delta.Length();
            float force = BIG_G * mi * mk / (r*r);
            delta.Normalize();
            b1->ApplyForce( force * delta, pi);
            b2->ApplyForce(-force * delta, pk);
        }
    }

In Topic: Big G the same at various screen sizes....

16 April 2013 - 04:00 AM

I don't think I need to scale the size of the objects. ... I need to keep the force constant between screen resolutions as the distance varies and on larger screens objects tske to long to start attracting

PARTNERS