finding fps
Blitz3D Forums/Blitz3D Beginners Area/finding fps
| ||
hi, I was wondering, how would I get Blitz to print the fps on screen? Thanks in advance |
| ||
..here you go... http://home.cmit.net/rwolbeck/programmingtutorial/ |
| ||
in your main loop do something like thisrepeat ;game stuff goes here, updateworld renderworld fpscount=fpscount+1 if millisecs()>fpstime then fpstime=millisecs()+1000 fps=fpscount fpscount=0 endif text 0,0,"FPS:"+fps flip until keydown(1) |
| ||
Here's one I use ... not sure who wrote it but you can set the update frequency.Global FPSlastupdatetime Global FPSframecount Global FPSlastcount# Function FPS(frequency=200) time=MilliSecs() FPSframecount=FPSframecount+1 elapsed#=time-FPSlastupdatetime If elapsed>=frequency FPSlastcount=FPSframecount/elapsed*1000.0 FPSframecount=0 FPSlastupdatetime=time EndIf Return FPSlastcount End Function |
| ||
I am a beginner to. But is the Function in this case not a bit out of tune. Cause you can call the function in a game loop more then one time. don't get me wrong. Its just a idea of it. |
| ||
Which function? You should be only calling a FPS once per main game loop. |
| ||
Here is one "halo" posted circa a year ago - I just found it whilst looking at other stuff - not sure how good it is, but it is one of "halo's" so it must be pretty good: This function will update the FPS every time period specified by the frequency parameter, which is set to 200 msecs by default. It takes an average of the elapsed time period, not just a measurement of the last frame. This also makes it easier to read the value when printed on the screen. Global FPSLASTUPDATETIME Global FPSFRAMECOUNT Global FPSLASTCOUNT# Function FPS#(frequency=200) time=MilliSecs() FPSFRAMECOUNT=FPSFRAMECOUNT+1 elapsed#=time-FPSLASTUPDATETIME If elapsed>=frequency FPSLASTCOUNT=FPSFRAMECOUNT/elapsed*1000.0 FPSFRAMECOUNT=0 FPSLASTUPDATETIME=time EndIf Return FPSLASTCOUNT End Function |