Code archives/Graphics/ShowFPS
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
A simple code to show the screen frame rate | |||||
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
| ||
Use this in your main program loop like this: [bbcode]While Not KeyHit(1) ;Cls() ;in blitz+ ;UpdateWorld() ;in blitz3d ;RenderWorld() ;in blitz3d Flip() ShowFPS(10,10) Wend [/bbcode] It would be nice if we could use syntax highlighting when submitting code into the archives. |
| ||
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 |
Code Archives Forum