o
    OZŽhÎ  ã                   @   sð  d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlZ	ej
 ej
 e¡¡d Zej
 ed¡ZdZdejv r<dZd	ejv rCd
Zd
Zdejv rLdZd
Zdejv rWdZdZdZdejv rcee	jN Zdejv rmee	jN Zdejv rwee	jN ZdZdejv r…ee	jN Zd
Zdejv ree	jN ZddgZdejv r©ej d¡Zeejed  ƒed< dejv r¿ej d¡Zeejed  ƒed< dejv Z e!eƒ G dd„ de	j"j#ƒZ$G dd„ de	j"j#ƒZ%		
	
		
	d dd„Z&e'dkröe&eeeee eƒ dS dS )!zó pg.examples.testsprite

Like the testsprite.c that comes with libsdl, this pygame version shows
lots of sprites moving around.

It is an abomination of ugly code, and mostly used for testing.


See pg.examples.aliens for some prettyier code.
é    N)Úrandint)Útime)ÚListÚdataTz-update_rectsz-noupdate_rectsFz-staticz-layered_dirtyz-flipz-fullscreenz-swz-hwz-scaledé€  éà  z-heighté   z-widthz-alphac                   @   s0   e Zd ZU g Zeej ed< dd„ Zdd„ Z	dS )ÚThingyÚimagesc                 C   sj   t jj | ¡ tjd | _| j ¡ | _t	dt
d ƒ| j_t	dt
d ƒ| j_t	ddƒt	ddƒg| _d| _d S )Nr   r   éÿÿÿÿé   )ÚpgÚspriteÚDirtySpriteÚ__init__r	   r
   ÚimageÚget_rectÚrectr   Úscreen_dimsÚxÚyÚvelZdirty©Úself© r   úI/var/www/auris/lib/python3.10/site-packages/pygame/examples/testsprite.pyr   e   s   
zThingy.__init__c                 O   sf   dD ].}| j | | j|  }|t| ks|dk r+| j|  | j|< | j | | j|  }|| j |< qd S )N)r   r   r   )r   r   r   )r   ÚargsÚkwargsÚiÚnvr   r   r   Úupdatep   s   ûzThingy.updateN)
Ú__name__Ú
__module__Ú__qualname__r
   r   r   ÚSurfaceÚ__annotations__r   r    r   r   r   r   r	   b   s   
 r	   c                   @   s(   e Zd ZU g Zeej ed< dd„ ZdS )ÚStaticr
   c                 C   s^   t jj | ¡ tjd | _| j ¡ | _t	ddt
d  d ƒ| j_t	ddt
d  d ƒ| j_d S )Nr   é   é   r   )r   r   r   r   r&   r
   r   r   r   r   r   r   r   r   r   r   r   r   |   s
   zStatic.__init__N)	r!   r"   r#   r
   r   r   r$   r%   r   r   r   r   r   r&   y   s   
 r&   ©r   r   c                 C   sÔ  |rd} t  ¡  t j ¡  t jj||dtjv d}t j ¡  t j ¡ }|dkr1t j d¡}| ¡  | 	g d¢¡ t j 
¡  t j tj td¡¡}	t j tj td¡¡}
trn|	 g d¢t jt jB ¡ |
 g d¢t jt jB ¡ n|	 g d¢t j¡ |
 g d¢t j¡ |r‹|	 ¡ }	|
 ¡ }
n|	 ¡ }	|
 ¡ }
|	gt_|r|
gt_ttjƒd	kr¹z	ttjd
 ƒ}W n ty¸   d}Y nw d}d}|rÅt j ¡ }n| rÍt j ¡ }nt j  ¡ }t!d|ƒD ]}|rç|d dkrç| "tƒ ¡ | "tƒ ¡ q×d}t#ƒ }t  $| %¡ ¡}| ¡ }| 	g d¢¡ d}|rU| s| 	g d¢¡ | r| &||¡ | '¡  | (|¡}| r0t j '|¡ nt j 
¡  t j) *¡ D ]}|j+t j,t j-t j,t j.fv rLd}q:|d	7 }|s
t#ƒ }t/d|||  d›ƒ t  0¡  dS )aÖ  Show lots of sprites moving around

    Optional keyword arguments:
    update_rects - use the RenderUpdate sprite group class (default True)
    use_static - include non-moving images (default False)
    use_layered_dirty - Use the FastRenderGroup sprite group (default False)
    screen_dims - Pygame window dimensions (default [640, 480])
    use_alpha - use alpha blending (default False)
    flags - additional display mode flags (default no additional flags)

    Tz-vsync)Zvsyncr   )r   r   r   zasprite.bmpz
static.png)éÿ   r*   r*   r   r   éd   Nr   FzFPS: Úf)1r   ÚinitÚdisplayÚset_modeÚsysÚargvÚjoystickZ	get_countZJoystickÚfillÚflipr   ÚloadÚosÚpathÚjoinÚdata_dirÚuse_rleZset_colorkeyZSRCCOLORKEYZRLEACCELZconvert_alphaÚconvertr	   r
   r&   ÚlenÚintÚ	Exceptionr   ZLayeredDirtyZRenderUpdatesÚGroupÚrangeÚaddr   r$   Úget_sizeÚclearr    ZdrawÚeventÚgetÚtypeZQUITZKEYDOWNZJOYBUTTONDOWNÚprintÚquit)Úupdate_rectsÚ
use_staticÚuse_layered_dirtyr   Ú	use_alphaÚflagsÚscreenZnum_joysticksZstickZsprite_surfaceZsprite_surface2Z
numspritesZspritesr   ÚframesÚstartÚ
backgroundZgoingZrectsrD   Úendr   r   r   Úmain„   sŠ   




ÿ


€ërS   Ú__main__)TFFr)   Fr   )(Ú__doc__r0   r6   Úrandomr   r   Útypingr   Zpygamer   r7   ÚsplitÚabspathÚ__file__Zmain_dirr8   r9   rI   r1   rJ   rK   rM   Z	DOUBLEBUFZ
FULLSCREENZ	SWSURFACEr:   Z	HWSURFACEZSCALEDr   Úindexr   r=   rL   rG   r   r   r	   r&   rS   r!   r   r   r   r   Ú<module>   sn   


















úuÿ