
    &h                        S r SSKJrJr  SSKJr  SSKJr  SSKrSSK	J
r
  SSKJr  SSKJr   " S	 S
5      r " S S\5      r " S S\5      r " S S\\5      r " S S\\" S5         5      r " S S\5      r\r\r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rS  r " S! S"5      rS# r " S$ S%5      rS& r S*S' jr!S*S( jr"S*S) jr#g)+a	  pygame module with basic game object classes

This module contains several simple classes to be used within games. There
are the main Sprite class and several Group classes that contain Sprites.
The use of these classes is entirely optional when using Pygame. The classes
are fairly lightweight and only provide a starting place for the code
that is common to most games.

The Sprite class is intended to be used as a base class for the different
types of objects in the game. There is also a base Group class that simply
stores sprites. A game could create new types of Group classes that operate
on specially customized Sprite instances they contain.

The basic Sprite class can draw the Sprites it contains to a Surface. The
Group.draw() method requires that each Sprite have a Surface.image attribute
and a Surface.rect. The Group.clear() method requires these same attributes
and can be used to erase all the Sprites with background. There are also
more advanced Groups: pygame.sprite.RenderUpdates() and
pygame.sprite.OrderedUpdates().

Lastly, this module contains several collision functions. These help find
sprites inside multiple groups that have intersecting bounding rectangles.
To find the collisions, the Sprites are required to have a Surface.rect
attribute assigned.

The groups are designed for high efficiency in removing and adding Sprites
to them. They also allow cheap testing to see if a Sprite already exists in
a Group. A given Sprite can exist in any number of groups. A game could use
some groups to control object rendering, and a completely separate set of
groups to control interaction or player movement. Instead of adding type
attributes or bools to a derived Sprite class, consider keeping the
Sprites inside organized Groups. This will allow for easier lookup later
in the game.

Sprites and Groups manage their relationships with the add() and remove()
methods. These methods can accept a single or multiple group arguments for
membership.  The default initializers for these classes also take a
single group or list of groups as arguments for initial membership. It is safe
to repeatedly add and remove the same Sprite from a Group.

While it is possible to design sprite and group classes that don't derive
from the Sprite and AbstractGroup classes below, it is strongly recommended
that you extend those when you create a new Sprite or Group class.

Sprites are not thread safe, so lock them yourself if using threads.

    )GenericTypeVar)WeakSet)warnN)Rect)	get_ticks)from_surfacec                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS r\S 5       r\R"                  S 5       rSrg)Spritec   a  simple base class for visible game objects

pygame.sprite.Sprite(*groups): return Sprite

The base class for visible game objects. Derived classes will want to
override the Sprite.update() method and assign Sprite.image and Sprite.rect
attributes.  The initializer can accept any number of Group instances that
the Sprite will become a member of.

When subclassing the Sprite class, be sure to call the base initializer
before adding the Sprite to Groups.

c                 P    [        5       U l        U(       a  U R                  " U6   g g N)set
_Sprite__gaddselfgroupss     E/var/www/auris/envauris/lib/python3.13/site-packages/pygame/sprite.py__init__Sprite.__init__r   s    5HHf     c                     U R                   R                  nU HV  n[        US5      (       a3  U" U5      (       d$  UR                  U 5        U R                  U5        ME  MG  U R                  " U6   MX     g)zadd the sprite to groups

Sprite.add(*groups): return None

Any number of Group instances can be passed as arguments. The
Sprite will be added to the Groups it is not already a member of.

_spritegroupN)r   __contains__hasattradd_internalr   r   r   hasgroups       r   r   
Sprite.addw   sb     hh##Eun--5zz&&t,%%e, " %  r   c                     U R                   R                  nU HV  n[        US5      (       a3  U" U5      (       a$  UR                  U 5        U R                  U5        ME  MG  U R                  " U6   MX     g)zremove the sprite from groups

Sprite.remove(*groups): return None

Any number of Group instances can be passed as arguments. The Sprite
will be removed from the Groups it is currently a member of.

r   N)r   r   r   remove_internalremover   s       r   r$   Sprite.remove   sb     hh##Eun--u::))$/((/  U# r   c                 :    U R                   R                  U5        g)zZ
For adding this sprite to a group internally.

:param group: The group we are adding to.
N)r   r   r   r    s     r   r   Sprite.add_internal   s     	Ur   c                 :    U R                   R                  U5        g)zb
For removing this sprite from a group internally.

:param group: The group we are removing from.
N)r   r$   r'   s     r   r#   Sprite.remove_internal   s     	r   c                     g)am  method to control sprite behavior

Sprite.update(*args, **kwargs):

The default implementation of this method does nothing; it's just a
convenient "hook" that you can override. This method is called by
Group.update() with whatever arguments you give it.

There is no need to use this method if not using the convenience
method by the same name in the Group class.

N )r   argskwargss      r   updateSprite.update   s    r   c                     U R                    H  nUR                  U 5        M     U R                   R                  5         g)a$  remove the Sprite from all Groups

Sprite.kill(): return None

The Sprite is removed from all the Groups that contain it. This won't
change anything about the state of the Sprite. It is possible to
continue to use the Sprite after this method has been called, including
adding it to Groups.

N)r   r#   clearr'   s     r   killSprite.kill   s.     XXE!!$' r   c                 ,    [        U R                  5      $ )zlist of Groups that contain this Sprite

Sprite.groups(): return group_list

Returns a list of all the Groups that contain this Sprite.

)listr   r   s    r   r   Sprite.groups   s     DHH~r   c                 ,    [        U R                  5      $ )zdoes the sprite belong to any groups

Sprite.alive(): return bool

Returns True when the Sprite belongs to one or more Groups.
)boolr   r7   s    r   aliveSprite.alive   s     DHH~r   c                 b    SU R                   R                   S[        U R                  5       S3$ )N<z Sprite(in 	 groups)>)	__class____name__lenr   r7   s    r   __repr__Sprite.__repr__   s*    4>>**+;s488}oYOOr   c                     U R                   $ )a  
Dynamic, read only property for protected _layer attribute.
This will get the _layer variable if it exists.

If you try to get it before it is set it will raise an attribute error.

Layer property can only be set before the sprite is added to a group,
after that it is read only and a sprite's layer in a group should be
set via the group's change_layer() method.

:return: layer as an int, or raise AttributeError.
_layerr7   s    r   layerSprite.layer   s     {{r   c                 P    U R                  5       (       d  Xl        g [        S5      eNzbCan't set layer directly after adding to group. Use group.change_layer(sprite, new_layer) instead.r;   rG   AttributeErrorr   values     r   rH   rI      $    zz||K  r   )__grG   N)rA   
__module____qualname____firstlineno____doc__r   r   r$   r   r#   r/   r3   r   r;   rC   propertyrH   setter__static_attributes__r,   r   r   r   r   c   sf    
!$$$P   \\	 	r   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )
WeakSprite   zA subclass of Sprite that references its Groups weakly. This
means that any group this belongs to that is not referenced anywhere
else is garbage collected automatically.
c                 d   > [         TU ]  " U6   [        U R                  5      U R                  S'   g )Nr   )superr   r   r   __dict__)r   r   r@   s     r   r   WeakSprite.__init__  s'    &!&-doo&>l#r   r,   )rA   rR   rS   rT   rU   r   rX   __classcell__)r@   s   @r   rZ   rZ      s    
? ?r   rZ   c                       \ rS rSrSrS rS rS r\S 5       r	\	R                  S 5       r	\S 5       r\R                  S	 5       rS
 rSrg)DirtySpritei  a  a more featureful subclass of Sprite with more attributes

pygame.sprite.DirtySprite(*groups): return DirtySprite

Extra DirtySprite attributes with their default values:

dirty = 1
    If set to 1, it is repainted and then set to 0 again.
    If set to 2, it is always dirty (repainted each frame;
    flag is not reset).
    If set to 0, it is not dirty and therefore not repainted again.

blendmode = 0
    It's the special_flags argument of Surface.blit; see the blendmodes in
    the Surface.blit documentation

source_rect = None
    This is the source rect to use. Remember that it is relative to the top
    left corner (0, 0) of self.image.

visible = 1
    Normally this is 1. If set to 0, it will not be repainted. (If you
    change visible to 1, you must set dirty to 1 for it to be erased from
    the screen.)

_layer = 0
    0 is the default value but this is able to be set differently
    when subclassing.

c                     SU l         SU l        SU l        [        U SS5      U l        S U l        [        R                  " U /UQ76   g )N   r   rG   )dirty	blendmode_visiblegetattrrG   source_rectr   r   r   s     r   r   DirtySprite.__init__&  sD    
  dHa0&v&r   c                 @    Xl         U R                  S:  a  SU l        gg)z9set the visible value (0 or 1) and makes the sprite dirty   rd   N)rg   re   )r   vals     r   _set_visibleDirtySprite._set_visible2  s    ::>DJ r   c                     U R                   $ )z'return the visible value of that sprite)rg   r7   s    r   _get_visibleDirtySprite._get_visible8  s    }}r   c                 "    U R                  5       $ )zp
You can make this sprite disappear without removing it from the group
assign 0 for invisible and 1 for visible
)rq   r7   s    r   visibleDirtySprite.visible<  s       ""r   c                 &    U R                  U5        g r   )rn   rN   s     r   rt   ru   D  s    % r   c                     U R                   $ )z
Layer property can only be set before the sprite is added to a group,
after that it is read only and a sprite's layer in a group should be
set via the group's change_layer() method.

Overwrites dynamic property from sprite class for speed.
rF   r7   s    r   rH   DirtySprite.layerH  s     {{r   c                 P    U R                  5       (       d  Xl        g [        S5      erK   rL   rN   s     r   rH   rx   S  rP   r   c                 j    SU R                   R                   S[        U R                  5       5       S3$ )Nr>   z DirtySprite(in r?   )r@   rA   rB   r   r7   s    r   rC   DirtySprite.__repr___  s1    ''((8T[[]9K8LIV	
r   )rG   rg   rf   re   ri   N)rA   rR   rS   rT   rU   r   rn   rq   rV   rt   rW   rH   rC   rX   r,   r   r   rb   rb     ss    >
' # # ^^! !   \\	 	
r   rb   c                       \ rS rSrSrSrg)WeakDirtySpriteie  zUA subclass of WeakSprite and DirtySprite that combines the benefits
of both classes.
r,   N)rA   rR   rS   rT   rU   rX   r,   r   r   r}   r}   e  s    r   r}   c                       \ rS rSrSrSrS rS r SS jrS r	S	 r
S
 rS rS rS rS rS rS r SS jrS rS rS rS rS rSrg)AbstractGroupik  a<  base class for containers of sprites

AbstractGroup does everything needed to behave as a normal group. You can
easily subclass a new group class from this or the other groups below if
you want to add more features.

Any AbstractGroup-derived sprite groups act like sequences and support
iteration, len, and so on.

Tc                      0 U l         / U l        g r   )
spritedictlostspritesr7   s    r   r   AbstractGroup.__init__z  s    r   c                 ,    [        U R                  5      $ )aN  get a list of sprites in the group

Group.sprites(): return list

Returns an object that can be looped over with a 'for' loop. (For now,
it is always a list, but this could change in a future version of
pygame.) Alternatively, you can get the same information by iterating
directly over the sprite group, e.g. 'for sprite in group'.

)r6   r   r7   s    r   spritesAbstractGroup.sprites~  s     DOO$$r   Nc                 "    SU R                   U'   g)z
For adding a sprite to this group internally.

:param sprite: The sprite we are adding.
:param layer: the layer to add to, if the group type supports layers
Nr   r   spriterH   s      r   r   AbstractGroup.add_internal  s     #'r   c                     U R                   U   nU(       a  U R                  R                  U5        U R                   U	 g)z_
For removing a sprite from this group internally.

:param sprite: The sprite we are removing.
N)r   r   append)r   r   	lost_rects      r   r#   AbstractGroup.remove_internal  s5     OOF+	##I.OOF#r   c                     XR                   ;   $ )zc
For checking if a sprite is in this group internally.

:param sprite: The sprite we are checking.
r   r   r   s     r   has_internalAbstractGroup.has_internal  s     ((r   c                 @    U R                  U R                  5       5      $ )zcopy a group with all the same sprites

Group.copy(): return Group

Returns a copy of the group that is an instance of the same class
and has the same sprites in it.

)r@   r   r7   s    r   copyAbstractGroup.copy  s     ~~LLN
 	
r   c                 4    [        U R                  5       5      $ r   )iterr   r7   s    r   __iter__AbstractGroup.__iter__      DLLN##r   c                 $    U R                  U5      $ r   )r   r   s     r   r   AbstractGroup.__contains__  s    xxr   c                 J   U Hd  n[        U[        5      (       a<  U R                  U5      (       d$  U R                  U5        UR                  U 5        MR  MT   U R                  " U6   Mf     g! [
        [        4 a    [        US5      (       aT  UR                  5        H=  nU R                  U5      (       a  M  U R                  U5        UR                  U 5        M?      M  U R                  U5      (       d&  U R                  U5        UR                  U 5         GM   GM  f = f)z|add sprite(s) to group

Group.add(sprite, list, group, ...): return None

Adds a sprite or sequence of sprites to a group.

r   N	
isinstancer   r   r   r   	TypeErrorrM   r   r   r   r   r   sprs       r   r   AbstractGroup.add  s     F &&))((00%%f-''- 12 HHf%  ">2 2
 v~66#)>>#3C#'#4#4S#9#9 $ 1 1# 6 # 0 0 6 $4 "..v66))&1++D11 72   A,,AD"8&D"!8D"!D"c                 J   U Hd  n[        U[        5      (       a<  U R                  U5      (       a$  U R                  U5        UR                  U 5        MR  MT   U R                  " U6   Mf     g! [
        [        4 a    [        US5      (       aT  UR                  5        H=  nU R                  U5      (       d  M  U R                  U5        UR                  U 5        M?      M  U R                  U5      (       a&  U R                  U5        UR                  U 5         GM   GM  f = f)zremove sprite(s) from group

Group.remove(sprite, list, or group, ...): return None

Removes a sprite or sequence of sprites from a group.

r   N)	r   r   r   r#   r$   r   rM   r   r   r   s       r   r$   AbstractGroup.remove  s     F&&))$$V,,((0**40 -
5KK(  ">2 5v~66#)>>#3C#0055 $ 4 4S 9 # 3 3D 9 $4 **622,,V4..t44 35r   c                    U(       d  gU HI  n[        U[        5      (       a  U R                  U5      (       d    gM2   U R                  " U6 (       d    gMK     g! [        [
        4 ab    [        US5      (       a4  UR                  5        H  nU R                  U5      (       a  M       g    M  U R                  U5      (       d     g M  f = f)a  ask if group has a sprite or sprites

Group.has(sprite or group, ...): return bool

Returns True if the given sprite or sprites are contained in the
group. Alternatively, you can get the same information using the
'in' operator, e.g. 'sprite in group', 'subgroup in group'.

Fr   T)r   r   r   r   r   rM   r   r   r   s       r   r   AbstractGroup.has  s     F&&))((00  1
)88V,$ - $  ">2 )v~66#)>>#3C#'#4#4S#9#9', $4  $0088#(  9)s$   AAC%C)C.C
Cc                 V    U R                  5        H  nUR                  " U0 UD6  M     g)zcall the update method of every member sprite

Group.update(*args, **kwargs): return None

Calls the update method of every member sprite. All arguments that
were passed to this method are passed to the Sprite update function.

N)r   r/   )r   r-   r.   r   s       r   r/   AbstractGroup.update"  s%     llnFMM4*6* %r   c           	      j  ^ U R                  5       n[        US5      (       a?  U R                  R                  [	        UUR                  U4S jU 5       5      5      5        O>U H8  nUR                  UR                  UR                  ST5      U R                  U'   M:     / U l	        U R                  nU$ )zdraw all sprites onto the surface

Group.draw(surface, special_flags=0): return Rect_list

Draws all of the member sprites onto the given surface.

blitsc              3   V   >#    U  H  oR                   UR                  S T4v   M      g 7fr   )imagerect).0r   special_flagss     r   	<genexpr>%AbstractGroup.draw.<locals>.<genexpr>=  s#      "NUsCHHdMBgs   &)N)
r   r   r   r/   zipr   blitr   r   r   )r   surfacebgsurfr   r   r   re   s      `   r   drawAbstractGroup.draw.  s     ,,.7G$$OO""MM "NU"  '.||IIsxx}($    r   c                 v   [        U5      (       aN  U R                   H  nU" X5        M     U R                  R                  5        H  nU(       d  M  U" X5        M     gUR                  nU R                   H  nU" X#U5        M     U R                  R                  5        H  nU(       d  M  U" X$U5        M     g)aM  erase the previous position of all sprites

Group.clear(surface, bgd): return None

Clears the area under every drawn sprite in the group. The bgd
argument should be Surface which is the same dimensions as the
screen surface. The bgd could also be a function which accepts
the given surface and the area to be cleared as arguments.

N)callabler   r   valuesr   )r   r   bgdlost_clear_rect
clear_rectsurface_blits         r   r2   AbstractGroup.clearL  s     C==#'#3#3G- $4"oo446
:, 7 #<<L#'#3#3S?C $4"oo446
: *= 7r   c                 v    U R                  5        H%  nU R                  U5        UR                  U 5        M'     g)zYremove all sprites

Group.empty(): return None

Removes all the sprites from the group.

N)r   r#   r   s     r   emptyAbstractGroup.emptye  s0     llnF  (""4( %r   c                 4    [        U R                  5       5      $ r   )r:   r   r7   s    r   __bool__AbstractGroup.__bool__q  r   r   c                 4    [        U R                  5       5      $ )zxreturn number of sprites in group

Group.len(group): return int

Returns the number of sprites contained in the group.

)rB   r   r7   s    r   __len__AbstractGroup.__len__t  s     4<<>""r   c                 N    SU R                   R                   S[        U 5       S3$ )Nr>   (z
 sprites)>)r@   rA   rB   r7   s    r   rC   AbstractGroup.__repr__~  s&    4>>**+1SYKzBBr   )r   r   r   Nr   )rA   rR   rS   rT   rU   r   r   r   r   r#   r   r   r   r   r   r$   r   r/   r   r2   r   r   r   rC   rX   r,   r   r   r   r   k  sv    	 L%  '	$)
$ !2F5@B
+ 34<>2
)$#Cr   r   Tc                       \ rS rSrSrS rSrg)Groupi  am  container class for many Sprites

pygame.sprite.Group(*sprites): return Group

A simple container for Sprite objects. This class can be subclassed to
create containers with more specific behaviors. The constructor takes any
number of Sprite arguments to add to the Group. The group supports the
following standard Python operations:

    in      test if a Sprite is contained
    len     the number of Sprites contained
    bool    test if any Sprites are contained
    iter    iterate through all the Sprites

The Sprites in the Group are not ordered, so the Sprites are drawn and
iterated over in no particular order.

c                 L    [         R                  U 5        U R                  " U6   g r   )r   r   r   r   r   s     r   r   Group.__init__  s    t$'r   r,   N)rA   rR   rS   rT   rU   r   rX   r,   r   r   r   r     s    &r   r   c                   "    \ rS rSrSrSS jrSrg)RenderUpdatesi  zGroup class that tracks dirty updates

pygame.sprite.RenderUpdates(*sprites): return RenderUpdates

This class is derived from pygame.sprite.Group(). It has an enhanced draw
method that tracks the changed areas of the screen.

Nc                    UR                   nU R                  n/ U l        UR                  nU R                  5        H  nU R                  U   nU" UR
                  UR                  S U5      n	U(       a?  U	R                  U5      (       a  U" U	R                  U5      5        OU" U	5        U" U5        OU" U	5        XR                  U'   M     U$ r   )	r   r   r   r   r   r   r   colliderectunion)
r   r   r   r   r   re   dirty_appendr   old_rectnew_rects
             r   r   RenderUpdates.draw  s    ||  ||llnFv.H#FLL&++t]SH''11 !9: * *X&&.OOF# % r   )r   r   )rA   rR   rS   rT   rU   r   rX   r,   r   r   r   r     s    r   r   c                   4    \ rS rSrSrS rS rS	S jrS rSr	g)
OrderedUpdatesi  ac  RenderUpdates class that draws Sprites in order of addition

pygame.sprite.OrderedUpdates(*sprites): return OrderedUpdates

This class derives from pygame.sprite.RenderUpdates().  It maintains
the order in which the Sprites were added to the Group for rendering.
This makes adding and removing Sprites from the Group a little
slower than regular Groups.

c                 @    / U l         [        R                  " U /UQ76   g r   )_spritelistr   r   r   s     r   r   OrderedUpdates.__init__  s    t.g.r   c                 6    U R                   R                  5       $ r   r   r   r7   s    r   r   OrderedUpdates.sprites  s    $$&&r   Nc                 d    [         R                  X5        U R                  R                  U5        g r   )r   r   r   r   r   s      r   r   OrderedUpdates.add_internal  s$    ""40'r   c                 d    [         R                  X5        U R                  R                  U5        g r   )r   r#   r   r$   r   s     r   r#   OrderedUpdates.remove_internal  s$    %%d3'r   r   r   )
rA   rR   rS   rT   rU   r   r   r   r#   rX   r,   r   r   r   r     s    	/'((r   r   c                       \ rS rSrSr\" SSSS5      rS rSS jrS r	S r
S	 rSS
 jrS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)LayeredUpdatesi  zLayeredUpdates Group handles layers, which are drawn like OrderedUpdates

pygame.sprite.LayeredUpdates(*sprites, **kwargs): return LayeredUpdates

This group is fully compatible with pygame.sprite.Sprite.
New in pygame 1.8.0

r   c                     0 U l         / U l        [        R                  U 5        UR	                  SS5      U l        U R                  " U0 UD6  g)a  initialize an instance of LayeredUpdates with the given attributes

You can set the default layer through kwargs using 'default_layer'
and an integer for the layer. The default layer is 0.

If the sprite you add has an attribute _layer, then that layer will be
used. If **kwarg contains 'layer', then the passed sprites will be
added to that layer (overriding the sprite._layer attribute). If
neither the sprite nor **kwarg has a 'layer', then the default layer is
used to add the sprites.

default_layerr   N)_spritelayersr   r   r   get_default_layerr   )r   r   r.   s      r   r   LayeredUpdates.__init__  sF      t$$jj!<'$V$r   Nc                    U R                   U R                  U'   Uc   UR                  nO[        US5      (       a  [        USU5        U R                  nU R                  nX$U'   [        U5      nS=pgUS-
  nXh::  a'  XhU-
  S-  -   nXCU      U::  a  US-   nOUS-
  nXh::  a  M'  Xu:  a"  XCU      U::  a  US-  nXu:  a  XCU      U::  a  M  UR                  Xq5        g! [         a    U R                  n[        USU5         Nf = f)WDo not use this method directly.

It is used by the group to add a sprite internally.

NrG   r   rd   rl   )
_init_rectr   rH   rM   r   setattrr   r   r   rB   insert)	r   r   rH   r   sprites_layerslenglowmidhighs	            r   r   LayeredUpdates.add_internal  s"    #'//=1 VX&&FHe,""++!&v 7|axk))Ccl+u4AgQw k j^CL9UB1HC j^CL9UBs#1 " 1++%01s   C #DDc                 z   U(       d  gSU;   a  US   OSnU Hg  n[        U[        5      (       a<  U R                  U5      (       d$  U R                  XC5        UR                  U 5        MR  MT   U R                  " U0 UD6  Mi     g! [
        [        4 a    [        US5      (       aT  UR                  5        H=  nU R                  U5      (       a  M  U R                  XS5        UR                  U 5        M?      M  U R                  U5      (       d&  U R                  XC5        UR                  U 5         GM   GM!  f = f)a  add a sprite or sequence of sprites to a group

LayeredUpdates.add(*sprites, **kwargs): return None

If the sprite you add has an attribute _layer, then that layer will be
used. If **kwarg contains 'layer', then the passed sprites will be
added to that layer (overriding the sprite._layer attribute). If
neither the sprite nor **kwarg has a 'layer', then the default layer is
used to add the sprites.

NrH   r   r   )r   r   r.   rH   r   r   s         r   r   LayeredUpdates.add  s    #*f#4w$F &&))((00%%f4''- 12 HHf//  ">2 2
 v~66#)>>#3C#'#4#4S#9#9 $ 1 1# = # 0 0 6 $4 "..v66))&8++D11 72s   -BAD:&D:98D:9D:c                 J   U R                   R                  U5        U R                  U   nX R                  La  U R                  R                  U5        [        US5      (       a%  U R                  R                  UR                  5        U R                  U	 U R                  U	 g)zFDo not use this method directly.

The group uses it to add a sprite.

r   N)	r   r$   r   r   r   r   r   r   r   )r   r   r   s      r   r#   LayeredUpdates.remove_internalI  s     	'??6*??*##H-66""##FKK0OOF#v&r   c                 6    U R                   R                  5       $ )zdreturn a ordered list of sprites (first back, last top).

LayeredUpdates.sprites(): return sprites

r   r7   s    r   r   LayeredUpdates.spritesZ  s     $$&&r   c                    U R                   nUR                  nU R                  n/ U l        UR                  nU R                  nU R                  5        Hu  n	XI   n
U" U	R                  U	R                  SU5      nXL a	  U" U5        O>UR                  U
5      (       a  U" UR                  U
5      5        OU" U5        U" U
5        XU	'   Mw     U$ )z~draw all sprites in the right order onto the passed surface

LayeredUpdates.draw(surface, special_flags=0): return Rect_list

N)
r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   re   r   	init_rectr   recnewrects               r   r   LayeredUpdates.drawb  s     __
||  ||OO	<<>C/C"399chhmLGW%&&s++ s!34 ) %%sO " r   c                     U R                   n[        US5      nUR                  U5      nU Vs/ s H  oRU   PM	     sn$ s  snf )zreturn a list with all sprites at that position

LayeredUpdates.get_sprites_at(pos): return colliding_sprites

Bottom sprites are listed first; the top ones are listed last.

)rd   rd   )r   r   collidelistall)r   pos_spritesr   colliding_idxis         r   get_sprites_atLayeredUpdates.get_sprites_at|  sE     ##C ++H5%23]]333s   ?c                      U R                   U   $ )zreturn the sprite at the index idx from the groups sprites

LayeredUpdates.get_sprite(idx): return sprite

Raises IndexOutOfBounds if the idx is not within range.

r   )r   idxs     r   
get_spriteLayeredUpdates.get_sprite  s     $$r   c                 F    U R                  U5      nU R                  " U6   U$ )z}remove all sprites from a layer and return them as a list

LayeredUpdates.remove_sprites_of_layer(layer_nr): return sprites

)get_sprites_from_layerr$   )r   layer_nrr   s      r   remove_sprites_of_layer&LayeredUpdates.remove_sprites_of_layer  s%     --h7Wr   c                 Z    [        [        U R                  R                  5       5      5      $ )zYreturn a list of unique defined layers defined.

LayeredUpdates.layers(): return layers

)sortedr   r   r   r7   s    r   layersLayeredUpdates.layers  s#     c$,,335677r   c                    U R                   nU R                  nUR                  U5        UR                  U5        [	        U5      nS=pgUS-
  nXh::  a'  XhU-
  S-  -   nXCU      U::  a  US-   nOUS-
  nXh::  a  M'  Xu:  a"  XCU      U::  a  US-  nXu:  a  XCU      U::  a  M  UR                  Xq5        [        US5      (       a  [        USU5        X$U'   g)change the layer of the sprite

LayeredUpdates.change_layer(sprite, new_layer): return None

The sprite must have been added to the renderer already. This is not
checked.

r   rd   rl   rG   N)r   r   r$   poprB   r   r   r   )	r   r   	new_layerr   r   r   r   r   r   s	            r   change_layerLayeredUpdates.change_layer  s     ""++v6" 7|axk))Ccl+y8AgQw k j^CL9YF1HC j^CL9YFs#68$$FHi0 "+vr   c                 L    U R                   R                  XR                  5      $ )zrreturn the layer that sprite is currently in

If the sprite is not found, then it will return the default layer.

)r   r   r   r   s     r   get_layer_of_sprite"LayeredUpdates.get_layer_of_sprite  s!     !!%%f.A.ABBr   c                 :    U R                   U R                  S      $ )zDreturn the top layer

LayeredUpdates.get_top_layer(): return layer

r   r   r7   s    r   get_top_layerLayeredUpdates.get_top_layer  s      !!$"2"22"677r   c                 :    U R                   U R                  S      $ )zJreturn the bottom layer

LayeredUpdates.get_bottom_layer(): return layer

r   r*  r7   s    r   get_bottom_layerLayeredUpdates.get_bottom_layer  s      !!$"2"21"566r   c                 B    U R                  XR                  5       5        g)zbring the sprite to front layer

LayeredUpdates.move_to_front(sprite): return None

Brings the sprite to front by changing the sprite layer to the top-most
layer. The sprite is added at the end of the list of sprites in that
top-most layer.

N)r#  r+  r   s     r   move_to_frontLayeredUpdates.move_to_front  s     	&"4"4"67r   c                 H    U R                  XR                  5       S-
  5        g)zmove the sprite to the bottom layer

LayeredUpdates.move_to_back(sprite): return None

Moves the sprite to the bottom layer by moving it to a new layer below
the current bottom layer.

rd   N)r#  r.  r   s     r   move_to_backLayeredUpdates.move_to_back  s      	&"7"7"9A"=>r   c                      U R                   S   $ )zKreturn the topmost sprite

LayeredUpdates.get_top_sprite(): return Sprite

r)  r   r7   s    r   get_top_spriteLayeredUpdates.get_top_sprite  s     ##r   c                     / nUR                   nU R                  nU R                   H   nXE   U:X  a
  U" U5        M  XE   U:  d  M    U$    U$ )a
  return all sprites from a layer ordered as they where added

LayeredUpdates.get_sprites_from_layer(layer): return sprites

Returns all sprites from a layer. The sprites are ordered in the
sequence that they where added. (The sprites are not removed from the
layer.

)r   r   r   )r   rH   r   sprites_appendsprite_layersr   s         r   r  %LayeredUpdates.get_sprites_from_layer  s\      **##C!U*s##e+  $ r   c                     U R                  U5      nU R                  U5       H  nU R                  XA5        M     U R                  " USU06  g)zswitch the sprites from layer1_nr to layer2_nr

LayeredUpdates.switch_layer(layer1_nr, layer2_nr): return None

The layers number must exist. This method does not check for the
existence of the given layers.

rH   N)r  r  r#  r   )r   	layer1_nr	layer2_nrsprites1r   s        r   switch_layerLayeredUpdates.switch_layer  sH     //	:..y9Cc- :8,y,r   )r   r   r   r   r   r   )rA   rR   rS   rT   rU   r   r   r   r   r   r#   r   r   r  r  r  r  r#  r&  r+  r.  r1  r4  r7  r  rA  rX   r,   r   r   r   r     s|     aAq!J%(#$J)2V'"'44%8"+HC87
8	?$,-r   r   c                       \ rS rSrSrS rSS jrSS jr\S 5       r	\S 5       r
S	 rS
 rSS jrS rS rS rS rSrg)LayeredDirtyi&  a  LayeredDirty Group is for DirtySprites; subclasses LayeredUpdates

pygame.sprite.LayeredDirty(*sprites, **kwargs): return LayeredDirty

This group requires pygame.sprite.DirtySprite or any sprite that
has the following attributes:
    image, rect, dirty, visible, blendmode (see doc of DirtySprite).

It uses the dirty flag technique and is therefore faster than
pygame.sprite.RenderUpdates if you have many static sprites.  It
also switches automatically between dirty rect updating and full
screen drawing, so you do no have to worry which would be faster.

As with the pygame.sprite.Group, you can specify some additional attributes
through kwargs:
    _use_update: True/False   (default is False)
    _default_layer: default layer where the sprites without a layer are
        added
    _time_threshold: threshold time for switching between dirty rect mode
        and fullscreen mode; defaults to updating at 80 frames per second,
        which is equal to 1000.0 / 80.0

New in pygame 1.8.0

c                     [         R                  " U /UQ70 UD6  SU l        SU l        SU l        SU l        UR                  5        H+  u  p4US;   d  M  [        X5      (       d  M  [        XU5        M-     g)a  initialize group.

pygame.sprite.LayeredDirty(*sprites, **kwargs): return LayeredDirty

You can specify some additional attributes through kwargs:
    _use_update: True/False   (default is False)
    _default_layer: default layer where the sprites without a layer are
        added
    _time_threshold: threshold time for switching between dirty rect
        mode and fullscreen mode; defaults to updating at 80 frames per
        second, which is equal to 1000.0 / 80.0

NFg      )@)_use_update_time_thresholdr   )	r   r   _cliprF  rG  _bgditemsr   r   )r   r   r.   keyrm   s        r   r   LayeredDirty.__init__A  sr     	9w9&9
 ,	HCJJwP P 3'	 'r   Nc                 >   [        US5      (       d
  [        5       e[        US5      (       d
  [        5       e[        US5      (       d
  [        5       e[        U[        5      (       d
  [	        5       eUR
                  S:X  a  SUl        [        R                  XU5        g)r   re   rt   rf   r   rd   N)r   rM   r   rb   r   re   r   r   r   s      r   r   LayeredDirty.add_internal]  s~     vw'' ""vy)) ""v{++ ""&+..+<<1FL##D%8r   c           	      z   UR                  5       nU R                  nUc  UnU R                  nU R                  nU R                  n[
        n	UR                  n
Ub  X l        U R                  nUR                  U5        [        5       nU R                  (       ai  U R                  UUU	UUUR                  U R                  5        Ub  Uc  SOUnU H  nU
" XX5        M     U R                  UU	UU
UU5        [        U5      nOwUb  Uc  SOUnU
" USSU5        U HS  nUR                   (       d  M  Uc  UR"                  OUnU
" UR$                  UR&                  UR(                  U5      UU'   MU     U	" U5      /n[        5       nUU-
  U R*                  :  a  SU l
        OSU l
        / USS& UR                  U5        U$ )a  draw all sprites in the right order onto the given surface

LayeredDirty.draw(surface, bgsurf=None, special_flags=None): return Rect_list

You can pass the background too. If a self.bgd is already set to some
value that is not None, then the bgsurf argument has no effect.
Passing a value to special_flags will pass that value as the
special_flags argument to pass to all Surface.blit calls, overriding
the sprite.blendmode attribute

Nr   )r   r   FT)get_cliprH  r   r   r   r   r   rI  set_clipr   rF  _find_dirty_arear   r   _draw_dirty_internalr6   rt   rf   r   r   ri   rG  )r   r   r   r   	orig_cliplatest_cliplocal_spriteslocal_old_rectlocal_update	rect_typesurf_blit_func	local_bgd
start_timeflagsr  	local_retr   end_times                     r   r   LayeredDirty.draws  s    $$&	jj#K((''	 III	% [
 !!## $*2'C"93> ( %% \*I$*2y&$>$;;;-:-BCMME*8		388S__e+N3' % #;/0I ;j 4#7#77$D#D Q 	#r   c                    U GHi  nUc  UR                   OUnUR                  S:  a  UR                  (       a  UR                  b\  U" UR                  R
                  UR                  R                  5      nUR                  S   US   -
  n	UR                  S   US   -
  n
OUR                  nUS   * n	US   * n
UR                  nUR                  U5       H8  nU" XL   5      nU" UR                  UUS   U	-   US   U
-   US   US   4U5        M:     GM  UR                  (       a+  U" UR                  UR                  UR                  U5      X'   UR                  S:X  d  GMb  SUl        GMl     g )Nrd   r   rl      )
rf   re   rt   ri   r   topleftsizeclipr  r   )	_old_rect_rectr  
_surf_blit_update_special_flagsr   r]  	_spr_rectrect_offset_xrect_offset_y_spr_rect_clipr  re  s                 r   rS  !LayeredDirty._draw_dirty_internal  sS    C%3%;CMMEyy1}??. !&chh&6&68L8L MI$'OOA$61$EM$'OOA$61$EM #I%.q\MM%.q\MM!*$33G<C)',7D		 Gm3 Gm3 G G	 
 = ;;%/		388S__e&IN 99> !CIK r   c                 r   U GH0  nUR                   S:  d  M  UR                  (       a2  U" UR                  R                  UR                  R                  5      nOU" UR                  5      nUR
                  n	UR                  n
U	" U5      nUS:  a  U
" XK   5        XK	 U	" U5      nUS:  a  M  U" UR                  U 5      5        X   ULd  M  U" X   5      nUR
                  n	UR                  n
U	" U5      nUS:  a  U
" XK   5        XK	 U	" U5      nUS:  a  M  U" UR                  U 5      5        GM3     g )Nr   r)  )re   ri   r   rc  rd  collidelistunion_ipre  )rH  rf  rg  r  ri  _update_appendr  r   _union_rect_union_rect_collidelist_union_rect_union_ipr  s               r   rR  LayeredDirty._find_dirty_area  s#    Cyy1}??"'(8(8#//:N:N"OK"'/K*5*A*A''2';';$+G4"f(4
/8A "f {//67>2"'	"7K.9.E.E++6+?+?(/8Ab&,WZ8#J3G< b& #;#3#3E#:;5 r   c                     X l         g)z?use to set background

Group.clear(surface, bgd): return None

N)rI  )r   r   r   s      r   r2   LayeredDirty.clear  s	     	r   c                     U R                   (       a5  U R                  R                  UR                  U R                   5      5        gU R                  R                  [	        U5      5        g)ztrepaint the given area

LayeredDirty.repaint_rect(screen_rect): return None

screen_rect is in screen coordinates.

N)rH  r   r   re  r   r   screen_rects     r   repaint_rectLayeredDirty.repaint_rect"  sG     ::##K$4$4TZZ$@A##D$56r   c                     Uc2  [         R                  R                  5       R                  5       U l        OXl        SU l        g)zzclip the area where to draw; pass None (default) to reset the clip

LayeredDirty.set_clip(screen_rect=None): return None

NF)pygamedisplayget_surfaceget_rectrH  rF  r{  s     r   rQ  LayeredDirty.set_clip/  s4     335>>@DJ$J r   c                     U R                   $ )zMget the area where drawing will occur

LayeredDirty.get_clip(): return Rect

)rH  r7   s    r   rP  LayeredDirty.get_clip;  s     zzr   c                 `    [         R                  XU5        UR                  S:X  a  SUl        gg)r   r   rd   N)r   r#  re   )r   r   r"  s      r   r#  LayeredDirty.change_layerC  s,     	##D)<<<1FL r   c                 F    [        S[        5        U R                  U5        g)am  set the threshold in milliseconds

set_timing_treshold(time_ms): return None

Defaults to 1000.0 / 80.0. This means that the screen will be painted
using the flip method rather than the update method if the update
method is taking so long to update the screen that the frame rate falls
below 80 frames per second.

Raises TypeError if time_ms is not int or float.

zHThis function will be removed, use set_timing_threshold function insteadN)r   DeprecationWarningset_timing_thresholdr   time_mss     r   set_timing_treshold LayeredDirty.set_timing_tresholdP  s"     	V	
 	!!'*r   c                     [        U[        [        45      (       a  Xl        g[	        SUR
                  R                   S35      e)an  set the threshold in milliseconds

set_timing_threshold(time_ms): return None

Defaults to 1000.0 / 80.0. This means that the screen will be painted
using the flip method rather than the update method if the update
method is taking so long to update the screen that the frame rate falls
below 80 frames per second.

Raises TypeError if time_ms is not int or float.

zExpected numeric value, got z insteadN)r   intfloatrG  r   r@   rA   r  s     r   r  !LayeredDirty.set_timing_thresholdc  sA     gU|,,#* .w/@/@/I/I.J(S r   )rI  rH  rG  rF  r   )NN)rA   rR   rS   rT   rU   r   r   r   staticmethodrS  rR  r2   r}  rQ  rP  r#  r  r  rX   r,   r   r   rD  rD  &  sd    4(89,Zx (" ("T < <>7
!+&r   rD  c                       \ rS rSrSrSS jrS rS rSS jrS r	S	 r
S
 r\S 5       r\R                  S 5       rS rS rS rSrg)GroupSingleix  a  A group container that holds a single most recent item.

This class works just like a regular group, but it only keeps a single
sprite in the group. Whatever sprite has been added to the group last will
be the only sprite in the group.

You can access its one sprite as the .sprite attribute.  Assigning to this
attribute will properly remove the old sprite and then add the new one.

Nc                 f    [         R                  U 5        S U l        Ub  U R                  U5        g g r   )r   r   _GroupSingle__spriter   r   s     r   r   GroupSingle.__init__  s.    t$HHV r   c                 ,    [        U R                  5      $ r   )r  r  r7   s    r   r   GroupSingle.copy  s    4==))r   c                 :    U R                   b  U R                   /$ / $ r   r  r7   s    r   r   GroupSingle.sprites  s    ==$MM?"	r   c                     U R                   b6  U R                   R                  U 5        U R                  U R                   5        Xl         g r   )r  r#   r   s      r   r   GroupSingle.add_internal  s5    ==$MM))$/  /r   c                     U R                   S L$ r   r  r7   s    r   r   GroupSingle.__bool__  s    }}D((r   c                     U R                   $ r   r  r7   s    r   _get_spriteGroupSingle._get_sprite  s    }}r   c                 J    U R                  U5        UR                  U 5        U$ r   )r   r   s     r   _set_spriteGroupSingle._set_sprite  s#    &!D!r   c                 "    U R                  5       $ )zN
Property for the single sprite contained in this group

:return: The sprite.
)r  r7   s    r   r   GroupSingle.sprite  s     !!r   c                 &    U R                  U5        g r   )r  )r   sprite_to_sets     r   r   r    s    'r   c                 x    XR                   L a  S U l         XR                  ;   a  [        R                  X5        g g r   )r  r   r   r#   r   s     r   r#   GroupSingle.remove_internal  s0    ]]" DM__$))$7 %r   c                     U R                   UL $ r   r  r   s     r   r   GroupSingle.has_internal      }}&&r   c                     U R                   UL $ r   r  r   s     r   r   GroupSingle.__contains__  r  r   )__spriter   )rA   rR   rS   rT   rU   r   r   r   r   r   r  r  rV   r   rW   r#   r   r   rX   r,   r   r   r  r  x  se    	*
)
 " " ]]( (8''r   r  c                 L    U R                   R                  UR                   5      $ )an  collision detection between two sprites, using rects.

pygame.sprite.collide_rect(left, right): return bool

Tests for collision between two sprites. Uses the pygame.Rect colliderect
function to calculate the collision. It is intended to be passed as a
collided callback function to the *collide functions. Sprites must have
"rect" attributes.

New in pygame 1.8.0

r   r   )leftrights     r   collide_rectr    s     99  ,,r   c                   *    \ rS rSrSrS rS rS rSrg)collide_rect_ratioi  a7  A callable class that checks for collisions using scaled rects

The class checks for collisions between two sprites using a scaled version
of the sprites' rects. Is created with a ratio; the instance is then
intended to be passed as a collided callback function to the *collide
functions.

New in pygame 1.8.1

c                     Xl         g)zcreate a new collide_rect_ratio callable

Ratio is expected to be a floating point value used to scale
the underlying sprite rect before checking for collisions.

Nratior   r  s     r   r   collide_rect_ratio.__init__  s	     
r   c           	          SR                  U R                  R                  [        U 5      S-  SR	                  S U R
                  R                  5        5       5      S9$ )
Turn the class into a string.
<{klass} @{id:x} {attrs}>  c              3   6   #    U  H  u  pU S U< 3v   M     g7f=Nr,   r   kvs      r   r   .collide_rect_ratio.__repr__.<locals>.<genexpr>       J4IDAaS!<4I   klassidattrsformatr@   rA   r  joinr^   rJ  r7   s    r   rC   collide_rect_ratio.__repr__  T    
 +11..))$x("((JDMM4G4G4IJJ 2 
 	
r   c                 <   U R                   nUR                  nUR                  nUR                  nUR	                  XS-  U-
  Xc-  U-
  5      nUR                  nUR                  nUR                  nUR	                  XS-  U-
  Xc-  U-
  5      nUR                  U5      $ )a=  detect collision between two sprites using scaled rects

pygame.sprite.collide_rect_ratio(ratio)(left, right): return bool

Tests for collision between two sprites. Uses the pygame.Rect
colliderect function to calculate the collision after scaling the rects
by the stored ratio. Sprites must have "rect" attributes.

)r  r   widthheightinflater   )r   r  r  r  leftrectr  r  	rightrects           r   __call__collide_rect_ratio.__call__  s     

99##EME$96>F;RSJJ	!!%%eme&;V^f=TU	##I..r   r  N	rA   rR   rS   rT   rU   r   rC   r  rX   r,   r   r   r  r    s    		
/r   r  c                 0   U R                   R                  UR                   R                  -
  nU R                   R                  UR                   R                  -
  nUS-  US-  -   n U R                  n UR                  nXEU-   S-  :*  $ ! [         a:    U R                   nSUR
                  S-  UR                  S-  -   S-  -  nXPl         NZf = f! [         a:    UR                   nSUR
                  S-  UR                  S-  -   S-  -  nXql         Nf = f)a`  detect collision between two sprites using circles

pygame.sprite.collide_circle(left, right): return bool

Tests for collision between two sprites by testing whether two circles
centered on the sprites overlap. If the sprites have a "radius" attribute,
then that radius is used to create the circle; otherwise, a circle is
created that is big enough to completely enclose the sprite's rect as
given by the "rect" attribute. This function is intended to be passed as
a collided callback function to the *collide functions. Sprites must have a
"rect" and an optional "radius" attribute.

New in pygame 1.8.0

rl         ?)r   centerxcenteryradiusrM   r  r  )	r  r  	xdistance	ydistancedistancesquared
leftradiusr  rightradiusr  s	            r   collide_circler  	  s   " 		!!EJJ$6$66I		!!EJJ$6$66IlY\1O![[
#ll K7A===#  !99 X^^Q.!1CCKL
 !  #JJ	 iooq093C3CQ3FF3NO"#s&   'B
 4C 
ACCADDc                   *    \ rS rSrSrS rS rS rSrg)collide_circle_ratioi4  aa  detect collision between two sprites using scaled circles

This callable class checks for collisions between two sprites using a
scaled version of a sprite's radius. It is created with a ratio as the
argument to the constructor. The instance is then intended to be passed as
a collided callback function to the *collide functions.

New in pygame 1.8.1

c                     Xl         g)a  creates a new collide_circle_ratio callable instance

The given ratio is expected to be a floating point value used to scale
the underlying sprite radius before checking for collisions.

When the ratio is ratio=1.0, then it behaves exactly like the
collide_circle method.

Nr  r  s     r   r   collide_circle_ratio.__init__@  s	     
r   c           	          SR                  U R                  R                  [        U 5      S-  SR	                  S U R
                  R                  5        5       5      S9$ )r  r  r  r  c              3   6   #    U  H  u  pU S U< 3v   M     g7fr  r,   r  s      r   r   0collide_circle_ratio.__repr__.<locals>.<genexpr>T  r  r  r  r  r7   s    r   rC   collide_circle_ratio.__repr__L  r  r   c                 X   U R                   nUR                  R                  UR                  R                  -
  nUR                  R                  UR                  R                  -
  nUS-  US-  -   n UR                  nXs-  n UR                  n	X-  n	XgU	-   S-  :*  $ ! [
         a:    UR                  nSUR                  S-  UR                  S-  -   S-  -  nXql         Nbf = f! [
         a:    UR                  n
SU
R                  S-  U
R                  S-  -   S-  -  n	Xl         Nf = f)ax  detect collision between two sprites using scaled circles

pygame.sprite.collide_circle_radio(ratio)(left, right): return bool

Tests for collision between two sprites by testing whether two circles
centered on the sprites overlap after scaling the circle's radius by
the stored ratio. If the sprites have a "radius" attribute, that is
used to create the circle; otherwise, a circle is created that is big
enough to completely enclose the sprite's rect as given by the "rect"
attribute. Intended to be passed as a collided callback function to the
*collide functions. Sprites must have a "rect" and an optional "radius"
attribute.

rl   r  )r  r   r  r  r  rM   r  r  )r   r  r  r  r  r  r  r  r  r  r  s              r   r  collide_circle_ratio.__call__W  s)     

II%%

(:(::	II%%

(:(::	#Q,A5	%J 	
	',,K 	#;"AAA!  	%yyH!2X__a5G!GC OPJ$K		%  	'

I)//1"4y7G7G7J"Js!RSK&L		's&   3B C% AC"!C"%AD)(D)r  Nr  r,   r   r   r  r  4  s    	
	
'Br   r  c                 l   UR                   S   U R                   S   -
  nUR                   S   U R                   S   -
  n U R                  n UR                  nUR                  XRU45      $ ! [         a    [        U R                  5      n NAf = f! [         a    [        UR                  5      n NYf = f)a  collision detection between two sprites, using masks.

pygame.sprite.collide_mask(SpriteLeft, SpriteRight): bool

Tests for collision between two sprites by testing if their bitmasks
overlap. If the sprites have a "mask" attribute, that is used as the mask;
otherwise, a mask is created from the sprite image. Intended to be passed
as a collided callback function to the *collide functions. Sprites must
have a "rect" and an optional "mask" attribute.

New in pygame 1.8.0

r   rd   )r   maskrM   r	   r   overlap)r  r  xoffsetyoffsetleftmask	rightmasks         r   collide_maskr    s     jjmdiil*Gjjmdiil*G,99.JJ	 I'9::  ,

+,  . -	.s$    A, B ,BBB32B3c                    U R                   R                  nU(       a  / nUR                  nUR                  5        H`  nUb)  U" X5      (       a  UR	                  5         U" U5        M-  M/  U" UR                   5      (       d  MH  UR	                  5         U" U5        Mb     U$ Ub!  U Vs/ s H  os" X5      (       d  M  UPM     sn$ U Vs/ s H  nU" UR                   5      (       d  M  UPM      sn$ s  snf s  snf )a  find Sprites in a Group that intersect another Sprite

pygame.sprite.spritecollide(sprite, group, dokill, collided=None):
    return Sprite_list

Return a list containing all Sprites in a Group that intersect with another
Sprite. Intersection is determined by comparing the Sprite.rect attribute
of each Sprite.

The dokill argument is a bool. If set to True, all Sprites that collide
will be removed from the Group.

The collided argument is a callback function used to calculate if two
sprites are colliding. it should take two sprites as values, and return a
bool value indicating if they are colliding. If collided is not passed, all
sprites must have a "rect" value, which is a rectangle of the sprite area,
which will be used to calculate the collision.

)r   r   r   r   r3   )r   r    dokillcollideddefault_sprite_collide_funccrashedr   group_sprites           r   spritecollider    s    , #)++"9"9!MMOL#F11 %%'<( 2 /|/@/@AA %%'<( , -2
-2\hv6TLU
 	
 "!L&|'8'89 	! 	
s   )C2=C2
C7)C7c                     0 n[         nU(       a?  U R                  5        H)  nU" XqX45      nU(       d  M  XU'   UR                  5         M+     U$ U  H  nU" XqX45      nU(       d  M  XU'   M     U$ )aC  detect collision between a group and another group

pygame.sprite.groupcollide(groupa, groupb, dokilla, dokillb):
    return dict

Given two groups, this will find the intersections between all sprites in
each group. It returns a dictionary of all sprites in the first group that
collide. The value for each item in the dictionary is a list of the sprites
in the second group it collides with. The two dokill arguments control if
the sprites from either group will be automatically removed from all
groups. Collided is a callback function used to calculate if two sprites
are colliding. it should take two sprites as values, and return a bool
value indicating if they are colliding. If collided is not passed, all
sprites must have a "rect" value, which is a rectangle of the sprite area
that will be used to calculate the collision.

)r  r   r3   )	groupagroupbdokilladokillbr   r  sprite_collide_funcgroup_a_sprite	collisions	            r   groupcollider    s}    $ G ($nn.N+NGVIy*3'##%	 / N	 %N+NGVIy*3' % Nr   c                     U R                   R                  nUb  U H  nU" X5      (       d  M  Us  $    gU H  nU" UR                   5      (       d  M  Us  $    g)a  finds any sprites in a group that collide with the given sprite

pygame.sprite.spritecollideany(sprite, group): return sprite

Given a sprite and a group of sprites, this will return any single
sprite that collides with the given sprite. If there are no
collisions, then this returns None.

If you don't need all the features of the spritecollide function, this
function will be a bit quicker.

Collided is a callback function used to calculate if two sprites are
colliding. It should take two sprites as values and return a bool value
indicating if they are colliding. If collided is not passed, then all
sprites must have a "rect" value, which is a rectangle of the sprite area,
which will be used to calculate the collision.


Nr  )r   r    r   r  r  s        r   spritecollideanyr    sb    , #)++"9"9!L--## "  "L*<+<+<==## " r   r   )$rU   typingr   r   weakrefr   warningsr   r  pygame.rectr   pygame.timer   pygame.maskr	   r   rZ   rb   r}   r   r   RenderPlainRenderClearr   r   r   rD  r  r  r  r  r  r  r  r  r  r,   r   r   <module>r     s
  *.D $     ! $U Up? ?\
& \
~j+ TCGGCL) TCnM 2 E <(] (8J-] J-Z
O> Od
C'- C'N- 7/ 7/t(>VJB JBZ;61h!H!r   