Motivation
The Timer class is a millisecond-precision timer that doesn't have its own thread, unlike the standard library's threading.Timer. It may be used for instance to achieve constant bitrate, though in my experience, just updating the scene as fast as possible is generally OK.
Usage
The constructor has the form
tmr = psp2d.Timer(tmo)
Where 'tmo' is the timer's delay, in milliseconds. The Timer class is actually an abstract class; you must subclass it and override the 'fire' method in order to use it. this method is called repeatedly at 'tmo' ms intervals. It must return True or the timer stops. To start the timer, you must invoke its 'run' method.
Examples
import psp2d class MyTimer(psp2d.Timer): def __init__(self): psp2d.Timer.__init__(self, 1000 / 25) # 25 fps def fire(self): # Draw stuff on the screen, swap buffers pad = psp2d.Controller() return not pad.circle # Exit the timer's run method if circle is down def main(): tmr = MyTimer() tmr.run()
