Ejemplo n.º 1
0
 def __init__(self, screen, dashboard, level, sound):
     self.screen = screen
     self.sound = sound
     self.start = False
     self.inSettings = False
     self.state = 0
     self.level = level
     self.music = True
     self.sfx = True
     self.currSelectedLevel = 1
     self.levelNames = []
     self.inChoosingLevel = False
     self.dashboard = dashboard
     self.levelCount = 0
     self.spritesheet = Spritesheet("./img/title_screen.png")
     self.menu_banner = self.spritesheet.image_at(
         0,
         60,
         2,
         colorkey=[255, 0, 220],
         ignoreTileSize=True,
         xTileSize=180,
         yTileSize=88,
     )
     self.menu_dot = self.spritesheet.image_at(0,
                                               150,
                                               2,
                                               colorkey=[255, 0, 220],
                                               ignoreTileSize=True)
     self.menu_dot2 = self.spritesheet.image_at(20,
                                                150,
                                                2,
                                                colorkey=[255, 0, 220],
                                                ignoreTileSize=True)
     self.loadSettings("./settings.json")
Ejemplo n.º 2
0
 def loadSprites(self, urlList):
     resDict = {}
     for url in urlList:
         with open(url) as jsonData:
             data = json.load(jsonData)
             mySpritesheet = Spritesheet(data['spriteSheetURL'])
             dic = {}
             if (data['type'] == "background"):
                 for sprite in data['sprites']:
                     try:
                         colorkey = sprite['colorKey']
                     except KeyError:
                         colorkey = None
                     dic[sprite['name']] = Sprite(
                         mySpritesheet.image_at(sprite['x'], sprite['y'],
                                                sprite['scalefactor'],
                                                colorkey),
                         sprite['collision'], None, sprite['redrawBg'])
                 resDict.update(dic)
                 continue
             elif data['type'] == "animation":
                 for sprite in data['sprites']:
                     images = []
                     for image in sprite['images']:
                         images.append(
                             mySpritesheet.image_at(
                                 image['x'],
                                 image['y'],
                                 image['scale'],
                                 colorkey=sprite['colorKey']))
                     dic[sprite['name']] = Sprite(
                         None,
                         None,
                         animation=Animation(images,
                                             deltaTime=sprite["deltaTime"]))
                 resDict.update(dic)
                 continue
             elif data['type'] == "character" or data['type'] == "item":
                 for sprite in data['sprites']:
                     try:
                         colorkey = sprite['colorKey']
                     except KeyError:
                         colorkey = None
                     dic[sprite['name']] = Sprite(
                         mySpritesheet.image_at(sprite['x'],
                                                sprite['y'],
                                                sprite['scalefactor'],
                                                colorkey,
                                                True,
                                                xTileSize=data['size'][0],
                                                yTileSize=data['size'][1]),
                         sprite['collision'])
                 resDict.update(dic)
                 continue
     return resDict
Ejemplo n.º 3
0
 def __init__(self,screen,dashboard,level,sound):
     self.screen = screen
     self.sound = sound
     self.start = False
     self.inSettings = False
     self.state = 0
     self.level = level
     self.dashboard = dashboard
     self.spritesheet = Spritesheet("./img/title_screen.png")
     self.menu_banner = self.spritesheet.image_at(0,60,2,colorkey=[255,0,220],ignoreTileSize=True,xTileSize=180,yTileSize=88)
     self.menu_dot = self.spritesheet.image_at(0,150,2,colorkey=[255,0,220],ignoreTileSize=True)
     self.loadSettings("./settings.json")
Ejemplo n.º 4
0
 def __init__(self, screen, entity, dashboard):
     self.screen = screen
     self.entity = entity
     self.dashboard = dashboard
     self.state = 0
     self.spritesheet = Spritesheet("./img/title_screen.png")
     self.pause_srfc = GaussianBlur().filter(self.screen, 0, 0, 640, 480)
     self.dot = self.spritesheet.image_at(
         0, 150, 2, colorkey=[255, 0, 220], ignoreTileSize=True
     )
     self.gray_dot = self.spritesheet.image_at(
         20, 150, 2, colorkey=[255, 0, 220], ignoreTileSize=True
     )
Ejemplo n.º 5
0
 def loadSprites(self, urlList):
     resDict = {}
     for url in urlList:
         with open(url) as jsonData:
             data = json.load(jsonData)
             mySpritesheet = Spritesheet(data["spriteSheetURL"])
             dic = {}
             if data["type"] == "background":
                 for sprite in data["sprites"]:
                     try:
                         colorkey = sprite["colorKey"]
                     except KeyError:
                         colorkey = None
                     dic[sprite["name"]] = Sprite(
                         mySpritesheet.image_at(
                             sprite["x"],
                             sprite["y"],
                             sprite["scalefactor"],
                             colorkey,
                         ),
                         sprite["collision"],
                         None,
                         sprite["redrawBg"],
                     )
                 resDict.update(dic)
                 continue
             elif data["type"] == "animation":
                 for sprite in data["sprites"]:
                     images = []
                     for image in sprite["images"]:
                         images.append(
                             mySpritesheet.image_at(
                                 image["x"],
                                 image["y"],
                                 image["scale"],
                                 colorkey=sprite["colorKey"],
                             )
                         )
                     dic[sprite["name"]] = Sprite(
                         None,
                         None,
                         animation=Animation(images, deltaTime=sprite["deltaTime"]),
                     )
                 resDict.update(dic)
                 continue
             elif data["type"] == "character" or data["type"] == "item":
                 for sprite in data["sprites"]:
                     try:
                         colorkey = sprite["colorKey"]
                     except KeyError:
                         colorkey = None
                     try:
                         xSize = sprite['xsize']
                         ySize = sprite['ysize']
                     except KeyError:
                         xSize, ySize = data['size']
                     dic[sprite["name"]] = Sprite(
                         mySpritesheet.image_at(
                             sprite["x"],
                             sprite["y"],
                             sprite["scalefactor"],
                             colorkey,
                             True,
                             xTileSize=xSize,
                             yTileSize=ySize,
                         ),
                         sprite["collision"],
                     )
                 resDict.update(dic)
                 continue
     return resDict