SyntaxBomb - Indie Coders
Languages & Coding => Blitz Code Archives => Graphics => Topic started by: BlitzBot on June 29, 2017, 00:28:40
Title : ShowFPS
Author : Captain Wicker (crazy hillbilly)
Posted : 1+ years ago
Description : A simple code to show the screen frame rate
Code :
Function ShowFPS(x#,y#)
timenow=MilliSecs()
If timenow>telltime Then
telltime=timenow+1000
getframes=frames
frames=0
Else
frames=frames+1
EndIf
Text x#,y#,getframes
End Function
Comments :
Captain Wicker (crazy hillbilly)(Posted 1+ years ago)
Use this in your main program loop like this:[bbcode]While Not KeyHit(1);Cls() ;in blitz+;UpdateWorld() ;in blitz3d;RenderWorld() ;in blitz3dFlip()ShowFPS(10,10)Wend[/bbcode]It would be nice if we could use syntax highlighting when submitting code into the archives.
misth(Posted 1+ years ago)
Hmm, didn't work in BlitzPlus. I guess you'll need globals for your function to work, like mine:Graphics 640,480,0,2
While Not KeyHit(1)
Cls()
a# = a + 1.0
For i = 0 To 36
x# = 320.0 + Cos(a + (i* 10.0)) * 100.0
y# = 240.0 - Sin(a + (i* 10.0)) * 100.0
Oval x-5, y-5, 10,10
Next
Text 0,0,FPS()
Flip(Not KeyDown(57))
Wend
Global gFPS, gRenders, gFPSTimer
Function FPS()
If MilliSecs() > gFPSTimer Then
gFPS = gRenders
gRenders = 0
gFPSTimer = MilliSecs() + 1000
Else
gRenders = gRenders + 1
End If
Return gFPS
End Function