Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualFs02

Posted 04 February 2013 - 01:09 PM

I want to make a game using Box2D v 2.2.1 and SFML 2, but i have a little problem with the physic simulation, its act strangely and different from when tested using default testbed.
 
I try to simulate the tire from behavior iforce.net tutorial that working well on the default testbed. 
 
my main code:

...
void GAME::GameLoading()
{
    testTire = new Tire(&_mainWorld);
    _gameState = gs_Playing;
}

void GAME::MainLoop()
{
    ...
    while (_mainWindow.isOpen())
    {
        switch (_gameState)
        {

            case gs_Loading:
            {
                GameLoading();
                break;
            }
            case gs_Playing:
            {
                _mainWindow.clear();
		_mainWorld.Step(1/60.f,6,2);
                testTire->updateFriction();
                DebugRender();
                _mainWindow.display();
                break;
            }
        }
	...
    }
}
...
b2Vec2 Gravity(10.f,0.f); //Make the tire move
b2World GAME::_mainWorld(Gravity);
Tire* GAME::testTire;
 

when i run this, the tire just move in x(gravity) axis with slow movement because the friction i made, but it wont move in y axis, i've try to rotate it a few degrees to but it doing the same.

 

please help me fix the code, i have worked on it for five days and still didn't find any solution.

 

Thaks smile.png

 

PS : Sorry for my bad english


#1Fs02

Posted 04 February 2013 - 12:28 PM

I want to make a game using Box2D and SFML, but i have a little problem with the physic simulation, its act strangely and different from when tested using default testbed.
 
I try to simulate the tire from behavior iforce.net tutorial that working well on the default testbed. 
 
my main code:

...
void GAME::GameLoading()
{
    testTire = new Tire(&_mainWorld);
    _gameState = gs_Playing;
}

void GAME::MainLoop()
{
    ...
    while (_mainWindow.isOpen())
    {
        switch (_gameState)
        {

            case gs_Loading:
            {
                GameLoading();
                break;
            }
            case gs_Playing:
            {
                _mainWindow.clear();
		_mainWorld.Step(1/60.f,6,2);
                testTire->updateFriction();
                DebugRender();
                _mainWindow.display();
                break;
            }
        }
	...
    }
}
...
b2Vec2 Gravity(10.f,0.f); //Make the tire move
b2World GAME::_mainWorld(Gravity);
Tire* GAME::testTire;
 

when i run this, the tire just move in x(gravity) axis with slow movement because the friction i made, but it wont move in y axis, i've try to rotate it a few degrees to but it doing the same.

 

please help me fix the code, i have worked on it for five days and still didn't find any solution.

 

Thaks smile.png

 

PS : Sorry for my bad english


PARTNERS