def activate(self): self.activated = True res.fadeoutMusic() self.maps = [] self.change_delay = 8000 # seconds until map moves to next point self.map_fadeout = 60.0 # must be a float self.last_update = 0 self.surfaceQueue = queue() self.subpixelQueue = queue() self.hotspots = cycle(([300,500], [750, 800], [350, 260], [700, 340], [120, 1000], [800, 830], [480, 900])) self.overworld = res.loadImage("overworld.png") self.menu = cMenu(Rect((42,20), sd.get_size()), 20, 5, 'vertical', 100, [('New Game', self.new_game), ('Battle Test', self.continue_game), ('Introduction', self.show_intro), ('Quit Game', self.quit_game)], font="northwoodhigh.ttf", font_size=24) self.menu.ready() self.change_map()
def deactivate(self): res.fadeoutMusic(1000) # unload the children for child in self.area.getChildren(): child.unload() self.area.music_pos = float(pygame.mixer.music.get_pos()) / 1000 SoundMan.unload()
def new_game(self): if self.game: [ i.unload() for i in self.game.getChildren() ] self.game.unload() self.game = None res.fadeoutMusic(1000) self.game = world.build() level = self.game.getChildByGUID(5001) self.parent.append(LevelState(level))
def reactivate(self): # play music if any has been set in tiled try: pygame.mixer.music.stop() res.playMusic(self.area.tmxdata.music, start=self.area.music_pos) except AttributeError: res.fadeoutMusic() self.music_playing = False else: self.music_playing = True
def continue_game(self): res.fadeoutMusic(1000) level = self.game.getChildByGUID(5001) self.parent.append(LevelState(level))
def new_game(self): res.fadeoutMusic(1000) self.game = world.build() level = self.game.getChildByGUID(5001) self.driver.append(LevelState(self.driver, level))
def continue_game(self): res.fadeoutMusic(1000) level = self.game.getChildByGUID(5001) self.driver.start(LevelState(level))
def activate(self): self.walkSound = None self.walkSoundDelay = 400 self.walkSoundPlaying = 0 self.sounds = {} self.msgFont = pygame.font.Font((res.fontPath("volter.ttf")), 9) self.border = gui.GraphicBox("dialog2-h.png", hollow=True) self.borderFilled = gui.GraphicBox("dialog2.png") self.player_vector = Vec2d(0,0) # get the root and the hero from it root = self.area.getRoot() self.hero = root.getChildByGUID(1) self.hero.move_speed = 1 # add the hero to this map if it isn't ready there if not self.area.hasChild(self.hero): self.area.add(self.hero) # load the tmx data here. it will be shared with the camera. self.tmxdata = tmxloader.load_pygame( self.area.mappath, force_colorkey=(128,128,0)) # attach a camera sw, sh = sd.get_size() mw = sw * .75 mh = sh * .75 self.camera = AreaCamera(self.area,((0,0), (mw, mh)), tmxdata=self.tmxdata) self.mapBorder = pygame.Rect((0,0,mw+6,mh+6)) self.msgBorder = pygame.Rect((0,mh,sw,sh-mh)) self.hudBorder = pygame.Rect((mw,0,sw-mw,mh+6)) # play music if any has been set in tiled try: res.playMusic(self.tmxdata.music) except AttributeError: res.fadeoutMusic() # quadtree for handling collisions with exit tiles rects = [] for guid, param in self.area.exits.items(): try: x, y, l = param[0] except: continue rects.append(ExitTile((x,y, self.tmxdata.tilewidth, self.tmxdata.tileheight), guid)) self.exitQT = QuadTree(rects) # load tile sounds for i, layer in enumerate(self.tmxdata.tilelayers): props = self.tmxdata.getTilePropertiesByLayer(i) for gid, tileProp in props: for key, value in tileProp.items(): if key[4:].lower() == "sound": self.sounds[value] = res.loadSound(value)
def new_game(self): res.fadeoutMusic(1000) self.game = world.build() level = self.game.getChildByGUID(5001) sd.start(LevelState(level))
def deactivate(self): GameState.deactivate(self) res.fadeoutMusic()