Bit of a noob here. I'm making a basic Pong clone game in C++ with SFML, but when I run the .exe on other computers the program runs (for most other PCs) slower. I've used Java before and used this way to regulate the amount of updates per second:
long lastTime = System.nanoTime();
final double ns = 1000000000.0 / 60.0;
double delta = 0;
while(running)
{
long now = System.nanoTime();
delta += (now - lastTime) / ns;
lastTime = now;
while(delta >= 1)
{
update();
delta--;
}
render();
}
}
I was planning on using this, but does C++ have anything like Java's System.nanoTime() method? How else could I make sure that my programs run at (or at least appear to run at) the same speed on different computers?
-Windows 7, VS2010.