def activate(self): global hero_body self.blank = True self.background = (109, 109, 109) self.foreground = (0, 0, 0) 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 = (0,0,0) self.hero_jump = 25 self.input_changed = False self.music_pos = 0.0 self.updateText = False self.messages = [] self.camera = None # allow the area to get needed data self.area.load() # load the children for child in self.area.getChildren(): child.load() # get the root and the hero from it root = self.area.getRoot() self.hero = root.getChildByGUID(1) self.hero.move_speed = 16 # add the hero to this map if it isn't ready there if not self.area.hasChild(self.hero): self.area.add(self.hero) hero_body = self.area.getBody(self.hero) # make a list of elevators in the level self.elevators = pytmx.buildDistributionRects(self.area.tmxdata, "Elevators", real_gid=None) # load sounds from area for filename in self.area.soundFiles: SoundMan.loadSound(filename) self.text = {} self.text['grab'] = "You grab onto {}" self.text['ungrab'] = "You let go of {}" self.reactivate()
except KeyError: pass props = data.getTilePropertiesByLayer(-1) """ print "GID MAP:" for k in sorted(data.gidmap.keys()): print " {}: {}\t{}".format(k, data.gidmap[k], data.getTilePropertiesByGID(data.gidmap[k])) """ # load the level geometry from the 'control' layer rects = [] for rect in buildDistributionRects(data, "Control", real_gid=1): rects.append(Rect(rect)) area.setLayerGeometry(0, rects) # build 'raw geometry' area.rawGeometry = [] for rect in rects: y, z = rect.topleft bbox = BBox((-100, y, z, 200, rect.width, rect.height)) area.rawGeometry.append(bbox) # load the npc's and place them in the default positions npcs = [ p for p in props if p[1].get('group', None) == 'npc' ]