I keep having this spike lag on my pong game
here is the code
while (window.isOpen())
{
window.setFramerateLimit(60);
sf::Event event;
dt = deltatime.getElapsedTime().asSeconds();
update(event,dt);
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
}
if (mClock.getElapsedTime().asSeconds() >= 1.f)
{
mFps = mFrame;
mFrame = 0;
mClock.restart();
}
++mFrame;
//std::cout << mFps << std::endl;
this->deltatime.restart();
window.clear(color);
player->Render(window);
ball->Render(window);
window.display();
}
IM guessing its the deltatime. But I dont see the connection. My computer is a medium gaming rig so I shouldnt have this lag spike.