I my gameloop goes round 10x sooner than what it must be and I do not know the right way to repair it.
I attempted a number of completely different different variable fee timesteps however none appear to be as efficient as this one.
int important(int argc, char* args[])
{
Uint32 t = 0;
Uint32 dt = 10000 / 60.0;
Uint32 currentTime = SDL_GetTicks();
recreation = new Renderer();
game->init("window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, false);
whereas(game->working()){
Uint32 newTime = SDL_GetTicks();
Uint32 frameTime = newTime - currentTime;
currentTime = newTime;
whereas(frameTime > 0.0)
{
float deltaTime = std::min(frameTime, dt);
game->handleEvents();
game->replace(deltaTime/1000);
frameTime -= deltaTime;
t += deltaTime;
t += dt;
}
game->render();
}
game->clear();
return 0;
}
At any time when I name
g.remodel.place.x+=1/60.0;
within the render operate, I count on it to maneuver 1 pixel each 1 second nevertheless it strikes method to quick.
Does anybody understand how I can gradual this down or what I am doing flawed?