My goal is make a loop, where function 'do_something()' is executed once every 5 seconds. I have code like this:
using namespace sf;
//(...)
Clock clock;
Time time;
//(...)
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
//some events...
}
time = clock.getElapsedTime();
if (time >= seconds(5.f))
{
do_something();
clock.restart();
}
}
This code execute my function in minimum possible time interval. I've tried every possible code options, that came into my mind, and all I achieved exept this, is application crash, or there is no reaction (statement never meet). This example looks so easy, that I don't know what can be wrong. Where I'm making mistake?