hello again,
i started experimenting around with box2d and created a game in simple billiard-style (i removed the gravity and used a few circle-shapes for collision and stuff).
everything works pretty excellent, but i guess that the step-thingy of the b2world-class isn't meant to be used in the way i plan it to use...
in my game i have an update-function which receives an integer called deltatime representing the time that passed since the last update-cycle. in this update-function i also update my b2world-object.
it looks somehow like that:
...and i want to bring the deltatime somehow in connection with the paramaters in m_world->Step but have no idea how...
any help appreciated! 🙂
i started experimenting around with box2d and created a game in simple billiard-style (i removed the gravity and used a few circle-shapes for collision and stuff).
everything works pretty excellent, but i guess that the step-thingy of the b2world-class isn't meant to be used in the way i plan it to use...
in my game i have an update-function which receives an integer called deltatime representing the time that passed since the last update-cycle. in this update-function i also update my b2world-object.
it looks somehow like that:
Quote:
void Update(uint32_t deltaTime)
{
m_world->Step(m_timeStep, m_iterations);
for (b2Contact* c = m_world->GetContactList(); c; c = c->GetNext())
{
if (c->GetManifoldCount() > 0)
{
b2Body* body1 = c->GetShape1()->GetBody();
b2Body* body2 = c->GetShape2()->GetBody();
float32 mass1 = body1->GetMass();
float32 mass2 = body2->GetMass();
if(mass1 > 0.0f && mass2 > 0.0f)
{
GetIconByBody(body1)->SetBallType(MathIcon::BallYellow);
GetIconByBody(body2)->SetBallType(MathIcon::BallYellow);
}
}
}
for(int i = 0; i < m_pieces.size(); i++)
m_pieces[i]->Update(deltaTime);
}
{
m_world->Step(m_timeStep, m_iterations);
for (b2Contact* c = m_world->GetContactList(); c; c = c->GetNext())
{
if (c->GetManifoldCount() > 0)
{
b2Body* body1 = c->GetShape1()->GetBody();
b2Body* body2 = c->GetShape2()->GetBody();
float32 mass1 = body1->GetMass();
float32 mass2 = body2->GetMass();
if(mass1 > 0.0f && mass2 > 0.0f)
{
GetIconByBody(body1)->SetBallType(MathIcon::BallYellow);
GetIconByBody(body2)->SetBallType(MathIcon::BallYellow);
}
}
}
for(int i = 0; i < m_pieces.size(); i++)
m_pieces[i]->Update(deltaTime);
}
...and i want to bring the deltatime somehow in connection with the paramaters in m_world->Step but have no idea how...
any help appreciated! 🙂