<s> from pyplatformerengine . utilities . Color import Color <EOL> from pyplatformerengine . models . SpritesheetLoader import SpritesheetLoader <EOL> import pygame <EOL> """<STR_LIT>""" <EOL> class SpritesheetFactory : <EOL> """<STR_LIT>""" <EOL> def createImages ( self , obj ) : <EOL> color = self . choosePredefinedColor ( obj [ "<STR_LIT>" ] ) <EOL> spriteStages = { } <EOL> for img in obj [ "<STR_LIT>" ] : <EOL> if img [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> spriteStages [ img [ "<STR_LIT:label>" ] ] = self . createGenericSurface ( img , color ) <EOL> elif img [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> spriteStages [ img [ "<STR_LIT:label>" ] ] = self . loadSpriteAnimations ( img , Color . BLACK ) <EOL> return spriteStages <EOL> """<STR_LIT>""" <EOL> def choosePredefinedColor ( self , colorName ) : <EOL> color = Color . BLACK <EOL> if colorName == "<STR_LIT>" : <EOL> color = Color . WHITE <EOL> elif colorName == "<STR_LIT>" : <EOL> color = Color . RED <EOL> elif colorName == "<STR_LIT>" : <EOL> color = Color . PINK <EOL> elif colorName == "<STR_LIT>" : <EOL> color = Color . BLUE <EOL> elif colorName == "<STR_LIT>" : <EOL> color = Color . GREEN <EOL> return color <EOL> """<STR_LIT>""" <EOL> def createGenericSurface ( self , img , color ) : <EOL> image = pygame . Surface ( ( img [ "<STR_LIT:width>" ] , img [ "<STR_LIT>" ] ) ) <EOL> image . fill ( color ) <EOL> return image <EOL> """<STR_LIT>""" <EOL> def loadSpriteAnimations ( self , img , color ) : <EOL> spritesheetLoader = SpritesheetLoader ( ) <EOL> spriteMap = spritesheetLoader . loadSpriteMap ( img [ "<STR_LIT:file>" ] ) <EOL> image = spritesheetLoader . imageAt ( spriteMap , ( img [ "<STR_LIT:x>" ] , img [ "<STR_LIT:y>" ] , img [ "<STR_LIT:width>" ] , img [ "<STR_LIT>" ] ) , color ) <EOL> return image </s>
