ó
-ÔĎTc           @   sš   d  d l  Z  d  d l Z e a g  Z d a d a d a d a	 d e  j
 f d     YZ d   Z d d d e d d  Z d	   Z d
   Z d   Z d   Z d   Z e e d d  Z d S(   i˙˙˙˙Ni    i   t	   NullScenec           B   s   e  Z d    Z RS(   c         C   s,   t  j j |  |  t  j d |  |  _ d  S(   Nt   size(   t   spyralt   Scenet   __init__t   Imaget
   background(   t   selfR   (    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyR      s    (   t   __name__t
   __module__R   (    (    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyR       s   c           C   s   t  j   d S(   s<   
    Cleanly quits out of spyral by emptying the stack.
    N(   R   t   _quit(    (    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   quit   s    s   My Spyral Gamec         C   s§   t  r d GHn  t j   d } t } t } | r@ | t j O} n  | rV | t j O} n  | rl | t j O} n  t j j	 |  |  a
 t a  t j j |  | a | a d S(   sR  
    Initializes the director. This should be called at the very beginning of
    your game.

    :param size: The resolution of the display window. (0,0) uses the screen
                 resolution
    :type size: :class:`Vec2D <spyral.Vec2D>`
    :param max_fps: The number of times that the director.update event will
                    occur per frame. This will remain the same, even if fps
                    drops.
    :type max_fps: ``int``
    :param max_ups: The number of frames per second that should occur when
                    your game is run.
    :type max_ups: ``int``
    :param fullscreen: Whether your game should start in fullscreen mode.
    :type fullscreen: ``bool``
    :param caption: The caption that will be displayed in the window.
                    Typically the name of your game.
    :type caption: ``str``
    s:   Warning: Tried to initialize the director twice. Ignoring.i    N(   t   _initializedR   t   _initt   Falset   pygamet	   RESIZABLEt   NOFRAMEt
   FULLSCREENt   displayt   set_modet   _screent   Truet   set_captiont   _max_upst   _max_fps(   R   t   max_upst   max_fpst
   fullscreent   captiont   flagst	   resizablet   noframe(    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   init   s"    
c           C   s%   y t  d SWn t k
 r  d SXd S(   sÎ   
    Returns the currently running scene; this will be the Scene on the top of
    the director's stack.

    :rtype: :class:`Scene <spyral.Scene>`
    :returns: The currently running Scene, or `None`.
    i˙˙˙˙N(   t   _stackt
   IndexErrort   None(    (    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt	   get_sceneK   s    c           C   s   t  S(   s  
    Returns the current tick number, where ticks happen on each update,
    not on each frame. A tick is a "tick of the clock", and will happen many
    (usually 30) times per second.

    :rtype: int
    :returns: The current number of ticks since the start of the game.
    (   t   _tick(    (    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   get_tickX   s    	c         C   s   t  r< t j j d d t  d t  j   } t j j   n  t  j |   t j j d d t j d |   d |  t	 j j
   d S(   st  
    Replace the currently running scene on the stack with *scene*.
    Execution will continue after this is called, so make sure you return;
    otherwise you may find unexpected behavior::

        spyral.director.replace(Scene())
        print "This will be printed!"
        return

    :param scene: The new scene.
    :type scene: :class:`Scene <spyral.Scene>`
    s   director.scene.exitt   scenei˙˙˙˙s   director.scene.entert   eventN(   R"   R   R)   t   handlet   popt   spritet   _switch_scenet   appendt   EventR   t   get(   R(   t   old(    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   replacec   s    c          C   s   t  t  d k  r d St j j d d t d t j   }  t j j   t rr t d }  t j j d d |  n t d  }  t j	 |   t
 j j   d S(	   sä   
    Pop the top scene off the stack, returning control to the next scene
    on the stack. If the stack is empty, the program will quit.
    This does return control, so remember to return immediately after
    calling it.
    i   Ns   director.scene.exitR(   i˙˙˙˙s   director.scene.enteriX  (   iX  iX  (   t   lenR"   R   R)   R*   R+   R,   R-   R    R.   R   R0   (   R(   (    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyR+   {   s    
c         C   sn   t  r: t j j d d t  d t  d } t j j   n  t  j |   t j j d d |  t j j   d S(   sí   
    Place *scene* on the top of the stack, and move control to it. This does 
    return control, so remember to return immediately after calling it. 

    :param scene: The new scene.
    :type scene: :class:`Scene <spyral.Scene>`
    s   director.scene.exitR(   i˙˙˙˙s   director.scene.enterN(	   R"   R   R)   R*   R,   R-   R.   R   R0   (   R(   R1   (    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   push   s    
c            sĺ    d k	 r t   n   r. d d l   n  t s8 d Sd } t     j } t } x t rŕ | d   | k	 rÓ | r | d k	 r d S j }  }  f d   }     f d   } | | _ | | _ n  | j	   qY Wd S(   s°  
    Begins running the game, starting with the scene on top of the stack. You
    can also pass in a *scene* to push that scene on top of the stack. This
    function will run until your game ends, at which point execution will end
    too.

    :param bool sugar: Whether to run the game for Sugar. This is only
                       to the special XO Launcher; it is safe to ignore.
    :param bool profiling: Whether to enable profiling mode, where this function
                           will return on every scene change so that scenes can
                           be profiled independently.
    :param scene: The first scene.
    :type scene: :class:`Scene <spyral.Scene>`
    i˙˙˙˙Nc            s5     j  d    j  d    j     j  d  d S(   s   
                A closure for handling drawing, which includes forcing the
                rendering-related events to be fired.
                s   director.pre_renders   director.renders   director.post_renderN(   t   _handle_eventt   _draw(   t   interpolation(   R(   (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   frame_callbackÂ   s    
c            sî    r& x   j    r"   j   q	 Wn  t t j j t j g   d k rd  j    j d  n   j	 j
    j	 j   } x' | D] }  j t j j |    q W j d   j d t j d |    t d 7a  j d  d S(	   s­   
                A closure for handling events, which includes firing the update
                related events (e.g., pre_update, update, and post_update).
                i    s   director.redraws   director.pre_updates   director.updatet   deltai   s   director.post_updateN(   t   events_pendingt   main_iterationR3   R   R)   R0   t   VIDEOEXPOSEt   redrawR5   t   _event_sourcet   tickt   _queue_eventR   t   _pygame_to_spyralR/   R&   (   R9   t   eventsR)   (   t   gtkR(   t   sugar(    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   update_callbackĚ   s    $
	
(
   R$   R4   RC   R"   R%   t   clockR   R8   RE   R?   (   RD   t	   profilingR(   t	   old_sceneRF   t   stackR8   RE   (    (   RC   R(   RD   sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   runĄ   s,    			
	
	(   i    i    (   R   R   R   R   R"   R$   R   R&   R   R   R   R    R   R!   R%   R'   R2   R+   R4   RJ   (    (    (    sB   /home/icarito/Proyectos/peru-learns-english/Lib/spyral/director.pyt   <module>   s(   	1					