³ò
Õ%Hc           @   sf   d  Z  d d k Z d d	 d „  ƒ  YZ e d j o0 d d k Z e i d d ƒ Z e i d ƒ GHn d S(
   s*   The start of a substitute Clock for pygameiÿÿÿÿNt   Clockc           B   s,   e  Z d  Z d „  Z d d „ Z d „  Z RS(   s  This class is generally used to limit the framerate of a game.

    Clock().tick(50) called in every frame will limit the framerate to 50
    frames per second. The tick method returns an int corresponding to the
    time since the last call to tick in milliseconds.
    c         C   s   t  i  ƒ  |  _ d |  _ d  S(   Niÿÿÿÿ(   t   timet   tt   rate(   t   self(    (    s:   /home/phil/rcs/svn/endgame-singularity/trunk/code/clock.pyt   __init__   s    iÿÿÿÿc         C   sL   | |  _  |  i ƒ  t t t i ƒ  |  i d d ƒ ƒ } t i ƒ  |  _ | S(   sg   If rate is specified this will limit the framerate to the
        specified number per second.
        iè  i    (   R   t   _stopt   intt   roundR   R   (   R   R   t   retVal(    (    s:   /home/phil/rcs/svn/endgame-singularity/trunk/code/clock.pyt   tick    s
    	
&c         C   sZ   y@ d |  i  t i ƒ  |  i } | d j o t i | ƒ n Wn t j
 o n Xd  S(   Ng      ð?i    (   R   R   R   t   sleept   IOError(   R   t
   sleep_time(    (    s:   /home/phil/rcs/svn/endgame-singularity/trunk/code/clock.pyR   +   s    (   t   __name__t
   __module__t   __doc__R   R
   R   (    (    (    s:   /home/phil/rcs/svn/endgame-singularity/trunk/code/clock.pyR       s   	t   __main__s
   c.tick(50)s'   from __main__ import Clock; c = Clock()iˆ  (    (   R   R   R    R   t   timeitt   Timert   timer(    (    (    s:   /home/phil/rcs/svn/endgame-singularity/trunk/code/clock.pys   <module>   s   %