Gonna try to fix the timestep to see how it goes. I'm currently just using the simplest:
// main.cpp
elapsed = timer.getElapsedTime(); // could've been restarting the clock here anyway
if (elapsed.asMicroseconds() >= 16666)
{
window.clear(sf::Color::Black);
coreState.update();
debuger.update();
coreState.draw(terminal);
terminal->render(&window);
debuger.draw(&window);
window.display();
if (!running) window.close();
timer.restart();
}
I didn't think it was relevant before, to show much of the code, as I didn't think the problem might be rooted somewhere else (and I wanted to receive answers solely focused on this, not other possible unrelated mistakes), but since now I think it is, this is what I was doing:
I was creating the clock in the World class, as a quick and dirty experimental thing, since it makes sense to me that the World class gets to manage the world's time (either that or a specific time manager class, is what I figured). I'm keeping some global variables in a separate database while I don't know enough to organize things better, and that includes the world's time and date variables (so that the UI can also access them and show the clock).
This is all stuff that may change in the future anyway. I may want to display a visual rotating sun and moon or something else entirely, and end up not needing global variables or even an actual clock display, but meanwhile I'm going with this, since the numbers help me see if it actually works as intended.
So I had two clocks. One in the main loop, that I copied from a youtube video some months ago, and the other in the World class. I suppose the clocks wouldn't interfere with each other, but now I think there's no point in having two. I can use the main one to pass the time to the database, or pass the time down the
update() functions.
Although, I wonder if sf::Clocks aren't something like sf::Fonts, that we shouldn't go wild with. I had never tried to actually understand timers and clocks until now.