I'm trying to limit my gameloop fps using SFML but it's not working correctly.
if I divide 60/1000 shouldn't the result be the time of each frame to get 60 FPS?
I put in 60 but I only get 33 does anyone know where I made a mistake?
Here is my header
class Game
{
//..
sf::Clock deltaTimeClock;
float deltaTime;
const float frameTime = 60.0f/ 1000.0f;
bool aSecondPassed();
float currentFPS = 0;
sf::Clock second;
//..
}
My implementation
//...
void Game::updateDeltaTime()
{
this->deltaTime = (this->deltaTimeClock.restart().asSeconds());
}
//...
void Game::run()
{
while (this->window->isOpen())
{
this->showFPS();
this->tick();
this->render();
while (deltaTime < this->frameTime)
{
this->deltaTime = this->deltaTimeClock.getElapsedTime().asSeconds();
}
this->updateDeltaTime();
}
}