error into my fps code

BlitzMax Forums/BlitzMax Beginners Area/error into my fps code

hub(Posted 2006) [#1]
Hi !
i don't understand... when i limit the fps to 60 with this code 62 is displayed as true fps !!! What's wrong ?
Thanks for the help !

Strict

Const CTE_FPS_LIMIT = 60

Function test_fps()
	
	Local FPS_time:Float = 1000 / CTE_FPS_LIMIT
	Local FPS_timer:Float = MilliSecs() + FPS_time	
	Local FPS_ms:Float	
	
	Local FPScurTime
	Local FPScheckTime
	Local CurFPS
	Local fpscounter	
	
	While Not KeyDown (KEY_ESCAPE)
	
	    FPS_ms = MilliSecs()
	    
		If (FPS_ms >= FPS_timer) Then

	    	FPS_timer = FPS_ms + FPS_time

			Cls	
			
			FPScurTime = MilliSecs()
			If FPScurTime > FPScheckTime Then
				FPScheckTime = FPScurTime + 1000
				curFPS = fpscounter
				fpscounter = 0
			Else
				fpscounter = fpscounter + 1
			End If		
			
			DrawText "FPS=" + String (CurFPS), 0,0
			
			Flip 0
			
		End If
		
	Wend
	
End Function

Graphics 1024 , 768 , 32 , 75

test_fps()	



Dreamora(Posted 2006) [#2]
1000 / 60 = 16
Correct 16.6666667


hub(Posted 2006) [#3]
i've updated the line

Local FPS_time:Float = 1000 / CTE_FPS_LIMIT

by

Local FPS_time:Float = 1000 / float (CTE_FPS_LIMIT)

now FPS displayed is 58 !?!!


hub(Posted 2006) [#4]
hope there is a method to update this code to display 60 ! i use this code in my game project !


BlackSp1der(Posted 2006) [#5]