Hi,

I have made a game (real time strategy) and it is running rather fast on my 3 GHz quad 8800 GTX, namely, it runs around 200 FPS usually when there are like 80 units and tanks in a forest fighting.

I would like to limit the FPS. So far my limitation code is pretty buggy... it does limit, but wrongly:

Code:
Private Sub LoopGame()
        Do While GameIsNotPaused
            FPS += 1
            If Math.Abs(Environment.TickCount - LastTick) >= 1000 / DesiredFrameRate Then
                ... draw ...
                LastTick = Environment.TickCount
                FPS = 0
            End If
            Application.DoEvents()
        Loop
    End Sub
I set desiredframerate to 90, and this code:
Code:
Public Class Framerate
    Private Shared lastTick As Integer
    Private Shared lastFrameRate As Integer
    Private Shared frameRate As Integer

    Public Shared Function CalculateFrameRate() As Integer
        frameRate += 1
        If Math.Abs(System.Environment.TickCount - lastTick) >= 1000 Then
            lastFrameRate = CType(frameRate * 1000 / Math.Abs(Environment.TickCount - lastTick), Integer)
            frameRate = 0
            lastTick = System.Environment.TickCount
        End If
        Return lastFrameRate
    End Function
End Class
Tells me that the game is running 64 FPS

Why 64, why not 90? What is wrong with that...

Also, after I solve this weird issue, should I set the value to monitor's refresh value which is usually 60 Hz on LCDs? Or should I set it to 30 or what ?