LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

FPS Counter?

Root / Programming Questions / [.]

MochaProbablyCreated:
I would like to know how to make a Frames Per Scond counter for my game.

MAINCNT returns the number of frames displayed since SmileBASIC was launched. You can take a MAINCNT value before, then take it again one second later, or sixty milliseconds, and find the difference in the values.

Usually what I do is something like:
VAR OLDMS=MILLISEC
VAR AVGSPEED=1/60*1000
WHILE 1
 ...
 VAR SPEED=MILLSEC-OLDMS 'get speed in milliseconds per frame
 OLDMS=MILLISEC
 AVGSPEED=(AVGSPEED*10+SPEED)/11'smoothing
 PRINT 1000/AVGSPEED 'convert to millisec/frame to frames/sec
WEND
The FPS will ideally be 59.834 (not 60)

Ah yes thanks, this will be helpful! The team iā€™m in has both the o3ds and n3ds so we needed to compare performance.