def load(self): self.loaded = True return res.loadSound(self.filename, *self.args, **self.kwargs)
def loadSound(self, filename): self.sounds[filename] = res.loadSound(filename) self.last_played[filename] = 0
def load(self): self.sound = res.loadSound(self.filename)
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)