Game Loop Speed on Different Machines
In my game loop, I have it Sleep for 50ms on each loop so the speed is appropriate for my machine. However, when I install in on other machines, 50ms may be too fast or too slow.
I realize I can give the user a speed up/slow down capability, but my game really needs to be a "standard" speed, so it looks the same on each machine -- otherwise the game dynamic is thrown off.
So anyone have a recommended, tried and true way to do this before I start experimenting?
Fullscreen DDraw Framerate Balancing
That's the verbose name for it. ^_^
Simply redraw as fast as you can, and in your game loop, do something like this:
Static LastTick as Long
Dim CurrentTick as Long, NextTime as Long, Framerate as Long
Framerate = 60 ' 60fps
CurrentTick = GetTickCount
If LastTick = 0 Then LastTick = CurrentTick
NextTime = LastTick + (1000 / (Framerate))
If CurrentTick >= NextTime Then
LastTick = CurrentTick
UpdateData ' Move all your sprites and stuff.
End If
Redraw ' Redraw.