This code has been declared by its author to be Public Domain code.
Download source code | mini frame counter by Kel | 2004 |
| |
|
well this is my firts contribution here, its a simple Fps displaying code, it displays the fps using a function with x,y parameters for the text position, nothing complicated but took me some hours to write(im new to programming).
hope you find some use to it. yes, i know you can do this with the command in blitz, but it is cool to find new ways to do things. Btw, i dont know if my code is corrects, but I get high fps in full screen mode. |
Graphics 640, 480, 32, 0
Global timer,fpscount,fpstemp,fps,x,y
SetBuffer BackBuffer()
timer=MilliSecs()
While Not KeyDown(1)
Cls
fps(0,0)
Flip
Wend
End
Function fps(x,y)
fpscount=fpscount+1
If MilliSecs()<timer+1000
Else
fps=fpscount-fpstemp
fpstemp=fpscount
timer=MilliSecs()
EndIf
Text x,y,"FPS "+fps
End Function |
Comments |
The way i do it, i reset fpscount to 0, after making fps equal it, that way it will always be within the range of an integer, and not overlap. im being a bit trivial with that though..
|
|
An easier method would be to just measure how many milliseconds have passed since the last frame and display : 1000 / that number. You could round that off to an integer value if you wanted for easier reading...
|
|
The idea of dividing by a potential 0 (happened to me) is stupid.
|
Code Archives Forum