#include <chrono>
#include <cstdint>
#include <iostream>
#include <thread>
int
main()
{
using namespace std;
using namespace std::chrono;
using frames = duration<int64_t, ratio<1, 5>>; // 5Hz
auto nextFrame = system_clock::now();
auto lastFrame = nextFrame - frames{1};;
while (true)
{
// Perform intersection test
this_thread::sleep_until(nextFrame);
cout << "Time: " // just for monitoring purposes
<< duration_cast<milliseconds>(system_clock::now() - lastFrame).count()
<< "ms
";
lastFrame = nextFrame;
nextFrame += frames{1};
}
}