Re: [VB6] Managed Game Loop
Would the following code extract do well with a DoEvents() in the loop, so that Windows can process other messages etc?
VB Code:
Private Sub Lock_Framerate(Target_FPS As Long)
Static Last_Time As Currency
Dim Current_Time As Currency
Dim FPS As Single
Do
QueryPerformanceCounter Current_Time
FPS = Ticks_Per_Second / (Current_Time - Last_Time)
' DoEvents here?
Loop While (FPS > Target_FPS)
QueryPerformanceCounter Last_Time
End Sub
Seems like there must be a way in Windows to setup a callback from a precision timer, so that the CPU doesn't go 100% loaded. I suppose this would require some C code...
Re: [VB6] Managed Game Loop
When it comes to games, almost all of them use 100% of the CPU. Don't worry about it. ;)