1201b7a57a14c6fa9c8c7f81285ecc8c53f4f729
1 """A timer for games with set-rate FPS.
7 """A timer for games with set-rate FPS.
12 def __init__(self
,fps
):
14 self
.tick
= self
._blank
17 self
.nt
= pygame
.time
.get_ticks()
24 """Wait correct amount of time each frame. Call this once per frame.
26 <pre>Timer.tick()</pre>
28 self
.ct
= pygame
.time
.get_ticks()
30 pygame
.time
.wait(self
.nt
-self
.ct
)
33 self
.nt
= pygame
.time
.get_ticks()+self
.wait
37 """A timer replacement that returns out FPS once a second.
38 <pre>Speedometer()</pre>
40 <strong>Attributes</strong>
42 <dt>fps <dd>always set to the current FPS
47 self
.st
= pygame
.time
.get_ticks()
51 """ Call this once per frame.
53 <pre>Speedometer.tick()</pre>
57 self
.ct
= pygame
.time
.get_ticks()
58 if (self
.ct
- self
.st
) >= 1000:
59 r
= self
.fps
= self
.frames
60 #print "%s: %d fps"%(self.__class__.__name__,self.fps)
63 pygame
.time
.wait(0) #NOTE: not sure why, but you gotta call this now and again
68 # vim: set filetype=python sts=4 sw=4 noet si :