<s> import pygame <EOL> import sys , os <EOL> class Asset ( object ) : <EOL> def __init__ ( self , spritesheet , spritemap ) : <EOL> self . spritesheet = pygame . image . load ( spritesheet ) <EOL> self . textfile = spritemap <EOL> self . sprites = [ ] <EOL> def load_sprites ( self ) : <EOL> info = open ( self . textfile , '<STR_LIT:r>' ) <EOL> lines = [ ] <EOL> for line in info : <EOL> lines . append ( line . split ( ) ) <EOL> for line in lines : <EOL> sprite = self . get_image ( int ( line [ <NUM_LIT:2> ] ) , int ( line [ <NUM_LIT:3> ] ) , int ( line [ <NUM_LIT:4> ] ) , int ( line [ <NUM_LIT:5> ] ) ) <EOL> self . sprites . append ( [ line [ <NUM_LIT:0> ] , sprite ] ) <EOL> def get_image ( self , x , y , width , height ) : <EOL> image = pygame . Surface ( ( width , height ) ) <EOL> image . blit ( self . spritesheet , ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( x , y , width , height ) ) <EOL> image . set_colorkey ( ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> return image <EOL> class PlayerAsset ( Asset ) : <EOL> def __init__ ( self , spritesheet , spritemap ) : <EOL> Asset . __init__ ( self , spritesheet , spritemap ) <EOL> self . load_sprites ( ) <EOL> def get_walk_frames ( self , color_code ) : <EOL> walk_frames = [ frame [ <NUM_LIT:1> ] for frame in self . sprites if color_code + "<STR_LIT>" in frame [ <NUM_LIT:0> ] ] <EOL> return walk_frames <EOL> def get_idle_frames ( self , color_code ) : <EOL> idle_frames = [ frame [ <NUM_LIT:1> ] for frame in self . sprites if color_code + "<STR_LIT>" in frame [ <NUM_LIT:0> ] ] <EOL> return idle_frames <EOL> def get_jump_frames ( self , color_code ) : <EOL> jump_frames = [ frame [ <NUM_LIT:1> ] for frame in self . sprites if color_code + "<STR_LIT>" in frame [ <NUM_LIT:0> ] ] <EOL> return jump_frames <EOL> def get_hurt_frames ( self , color_code ) : <EOL> hurt_frames = [ frame [ <NUM_LIT:1> ] for frame in self . sprites if color_code + "<STR_LIT>" in frame [ <NUM_LIT:0> ] ] <EOL> return hurt_frames <EOL> class BlockAssets ( Asset ) : <EOL> def __init__ ( self , spritesheet , spritemap ) : <EOL> Asset . __init__ ( self , spritesheet , spritemap ) <EOL> self . load_sprites ( ) <EOL> def get_frame ( self ) : <EOL> return self . sprites [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] </s>
