Cześć! Próbowałem zaimplementować fixed time step z https://gafferongames.com/post/fix_your_timestep/ tego poradnika
void MainLoop()
{
float t = 0.0f;
float deltaT= 0.01;
float currentTime = SDL_GetTicks();
float accumulator = 0.0f;
while (!quit) {
float newTime = SDL_GetTicks();
float frameT = newTime - currentTime;
currentTime = newTime;
accumulator += frameT;
while (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
exit(0);
}
Input(event);
}
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
while (accumulator >= deltaT)
{
Update(deltaT);
t += deltaT;
accumulator -= deltaT;
}
Draw(renderer);
SDL_RenderPresent(renderer);
}
}
W tym poradniku delta time ustawiona jest na 0.01 i się w ogóle nie zmienia. Skoro tak, to w jaki sposób ma zmieniać się moja prędkość/pozycja czy cokolwiek co jest oparte na dt skoro jest to stała wartość?
Również pod odpaleniu aplikacji, niektóre animacje robiły się bardzo bardzo szybko, a inne z kilkusekundowym opóźnieniem.
W jaki sposób mógłbym to naprawić?