Code archives/Algorithms/FPS module
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Import and go, absolutely nothing required except Import, and call functions. Only works in Max2D. | |||||
Module Rat.FramesPerSecond ModuleInfo "Description: Does simple frame rate tracking in less than 50 lines of code." ModuleInfo "Author: Bill Whitacre (ninjarat)" ModuleInfo "Version: 1.0" Private Global fpsobject:CFps=New CFps Type CFps Field ms#,oms#,fps#,mspf# Method getFps() ms=MilliSecs() mspf=ms-oms fps=1000*(mspf^-1) oms=ms End Method End Type Function internalUpdate() fpsobject.getFps End Function Function internalFPS#(update) If update Then internalUpdate Return fpsobject.fps End Function Function internalMSPF#(update) If update Then internalUpdate Return fpsobject.mspf End Function Public Function FPSUpdate() internalUpdate End Function Function FPS#(update=True) Return internalFPS(update) End Function Function MSPF#(update=True) Return internalMSPF(update) End Function |
Comments
| ||
Rather than simply counting the frames in a second, it takes the amount of time in milliseconds of the frame and calculates the actual ratio. |
Code Archives Forum