Hi.... sorry for this very noob question but... i'm starting with "Game Programming" and for me more algoritms are confuse...
Ok... i have problems when i try sync box2D World with the "Game Loop"... SFML works fine... but box2D update positions & forces very fast in Linux and ~fast in Windows.....
TIMESTEP DECLARATION:
const float TIMESTEP = 1.0f / 60.0f;
GAMELOOP:
//Update Box2D
if (time_step_box2D.GetElapsedTime() >= 0.001)
{
world.world->Step(TIMESTEP, 10);
time_step_box2D.Reset();
}
//updatePhysics();
//Update Camera Pos
camera.move();
if (!world.paused && time_step.GetElapsedTime() >= TIMESTEP) {
//world.world->Step(TIMESTEP, 10);
//screen.Clear();
draw_game();
draw_player_hud();
screen.Display();
time_step.Reset();
}
//CPU by happy :)
#ifndef __WIN32
usleep(1);
#else
Sleep(1);
#endif
Sry for my bad english :\