def load_game(self): try: path = os.path.join("resources", "saves", "save") self.game = loadObject(path) except IOError: return self.new_game() level = self.game.getChildByGUID(5001) sd.start(LevelState(level))
def update(self, time): if self.queue_dialog: if self.cleared: sd.start(self.queue_dialog) self.queue_dialog = None self.cleared = False else: try: text = self.dialogs.pop() except IndexError: sd.done() return if text[:6] == "#image": fill = False tag, path = text.split(":") if path[0] == "+": fill = True path = path[1:] if tag[-8:] == "colorkey": image = res.loadImage(path, colorkey=1) elif tag[-5:] == "alpha": image = res.loadImage(path, alpha=1) else: image = res.loadImage(path) rect = image.get_rect() if fill: size = [ int(i) for i in sd.get_size() ] x = size[0] - rect.w y = size[1] - rect.h r = float(rect.w) / rect.h if x > y: rect = pygame.Rect((0,0,size[0],size[1]*r)) else: rect = pygame.Rect((0,0,size[0]*r,size[1])) rect.center = size[0] / 2, size[1] / 2 image = pygame.transform.smoothscale(image, rect.size) else: rect.topleft = ((sd.get_size()[0]/2)-(rect.width/2), 10) self.queue_image = (image, rect) self.cleared = False elif text[:6] == "#music": tag, path = text.split(":") self.queue_music = path else: self.queue_dialog = TextDialog(text)
def continue_game(self): res.fadeoutMusic(1000) level = self.game.getChildByGUID(5001) sd.start(LevelState(level))
def new_game(self): res.fadeoutMusic(1000) self.game = world.build() level = self.game.getChildByGUID(5001) sd.start(LevelState(level))