[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] 100% CPU FAQ



Incidentally, if you say "start_time = time.time()" when starting your
program, then get the time when ending, subtract start_time, and divide by
the number of frames drawn, you get an easy FPS counter.

I noticed pygame has functionality for this inbuilt.

Clock.get_fps(),

"Compute your game's framerate (in frames per second). It is computed by averaging the last few calls to Clock.tick - update the clock"

Documentation:
http://www.pygame.org/docs/ref/time.html#Clock.get_fps

Examples:
http://www.google.com/codesearch?q=file%3A\.py%24+pygame+Clock.get_fps