Ñò
HjRLc           @   sG   d  d k  Z  d  d k Z d  d k Z d  d k Z d d d „  ƒ  YZ d S(   iÿÿÿÿNt   Animatec           B   sh   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z RS(   s(   
    Base class for Animate objects
    c         C   sL   t  i i | ƒ i ƒ  |  _ | |  _ | |  _ d |  _ t |  _ t	 |  _
 d  S(   Nid   (   t   pygamet   imaget   loadt   convertt   locationt   namet   healtht   Truet   alivet   Falset   awake(   t   selfR   t	   imagefileR   (    (    s.   C:\Python26\knight_game\knight_game\animate.pyt   __init__   s    				c         C   sJ   |  i  o< t i |  i | ƒ o& | i |  i t i |  i | ƒ ƒ n d S(   st   
        Draw the item to the screen. 
        screen_rect is the current viewing window in abs coordinates
        N(   R	   t   displayt   is_on_screenR   t   blitR   t   abs_to_screen(   R   t   screent   screen_rect(    (    s.   C:\Python26\knight_game\knight_game\animate.pyt   draw   s     &c         C   s    |  i  o |  i i t ƒ } | S(   sb   
        Returns if the inanimate oject is colliding with something(using rect collision)
        (   R	   R   t   colliderectt   other(   R   t   rectt	   colliding(    (    s.   C:\Python26\knight_game\knight_game\animate.pyR      s    c         C   si   t  i t  i |  i i | i d ƒ t  i |  i i | i d ƒ ƒ } | d j  } | o t |  _ n | S(   Ni   id   (   t   matht   sqrtt   powR   t   centerxt   centeryR   R   (   R   R   t   distancet   near(    (    s.   C:\Python26\knight_game\knight_game\animate.pyt   nearby   s    "#c         C   s³  |  i  | i ƒ p
 |  i o’|  i i t i d d ƒ t i d d ƒ f ƒ xa| i D]R} | i |  i ƒ o9t |  i i	 | i i
 ƒ d j o4 | i |  ƒ | i ƒ  o | i i
 |  i _	 q£q§t |  i i
 | i i	 ƒ d j o4 | i |  ƒ | i ƒ  o | i i	 |  i _
 q£q§t |  i i | i i ƒ d j o4 | i |  ƒ | i ƒ  o | i i |  i _ q£q§| i |  ƒ | i ƒ  o | i i |  i _ q§qU qU Wn d  S(   Niþÿÿÿi   i   (   R!   R   R   t   move_ipt   randomt	   randranget
   inanimatesR   t   abst   bottomt   topt   touched_from_topt   is_solidt   touched_from_bottomt   rightt   leftt   touched_from_leftt   touched_from_right(   R   t   levelt   knightt	   inanimate(    (    s.   C:\Python26\knight_game\knight_game\animate.pyt   update&   s(    .
 ###c         C   s   d S(   sV   
        Called when the knight collides with the inanimate object from above
        N(    (   R   R1   (    (    s.   C:\Python26\knight_game\knight_game\animate.pyR)   >   s    c         C   s   d S(   sV   
        Called when the knight collides with the inanimate object from below
        N(    (   R   R1   (    (    s.   C:\Python26\knight_game\knight_game\animate.pyR+   C   s    c         C   s   d S(   sY   
        Called when the knight collides with the inanimate object from the left
        N(    (   R   R1   (    (    s.   C:\Python26\knight_game\knight_game\animate.pyR.   H   s    c         C   s   d S(   sZ   
        Called when the knight collides with the inanimate object from the right
        N(    (   R   R1   (    (    s.   C:\Python26\knight_game\knight_game\animate.pyR/   M   s    c         C   s   t  S(   sj   
        Returns if the inanimate object is solid(meaning animate objects cannot walk through it)
        (   R
   (   R   (    (    s.   C:\Python26\knight_game\knight_game\animate.pyR*   R   s    (   t   __name__t
   __module__t   __doc__R   R   R   R!   R3   R)   R+   R.   R/   R*   (    (    (    s.   C:\Python26\knight_game\knight_game\animate.pyR       s   										(    (   R   R   R   R#   R    (    (    (    s.   C:\Python26\knight_game\knight_game\animate.pyt   <module>   s   0