def activate(self): GameState.activate(self) w, h = sd.get_size() self.cr_open = scale(res.loadImage("open.png", 0, 1), (20,30)) self.cr_grasp = scale(res.loadImage("grasp.png", 0, 1), (20, 25)) self.cr_arrow = res.loadImage("next_arrow.png", 0, 1) self.cr = KeyCursor(self.cr_open) self.cr_state = HAND_OPEN self.cr_bounds = Rect(0,0,w,h).inflate(-w*.2, -h*.2) self.cr_bounds.height -= 30 self.cr_bounds.width -= 20 self.cr_pos = list(self.cr_bounds.center) self.cr_speed = 0 self.cr.enable() self.map_pos = self.cr_pos[:] path = res.mapPath("overworld3.tmx") self.tilemap = BufferedTilemapRenderer(path, (w,h), force_colorkey=(128,0,63)) self.camera = OverworldCamera([], self.tilemap, ((0,0), (w,h))) self.camera.center(self.cr_pos) self.tilemap.redraw() self.cleared = 0
def activate(self): GameState.activate(self) w, h = sd.get_size() self.cr_open = scale(res.loadImage("open.png", 0, 1), (20, 30)) self.cr_grasp = scale(res.loadImage("grasp.png", 0, 1), (20, 25)) self.cr_arrow = res.loadImage("next_arrow.png", 0, 1) self.cr = KeyCursor(self.cr_open) self.cr_state = HAND_OPEN self.cr_bounds = Rect(0, 0, w, h).inflate(-w * .2, -h * .2) self.cr_bounds.height -= 30 self.cr_bounds.width -= 20 self.cr_pos = list(self.cr_bounds.center) self.cr_speed = 0 self.cr.enable() self.map_pos = self.cr_pos[:] path = res.mapPath("overworld3.tmx") self.tilemap = BufferedTilemapRenderer(path, (w, h), force_colorkey=(128, 0, 63)) self.camera = OverworldCamera([], self.tilemap, ((0, 0), (w, h))) self.camera.center(self.cr_pos) self.tilemap.redraw() self.cleared = 0
# for platformer maps def toWorld(data, (x, y, z)): """ translate tiled map coordinates to world coordinates """ return z, x*data.tilewidth, (y-1)*data.tileheight # for zelda-style games #def toWorld(data, (x, y, l)): # """ translate tiled map coordinates to world coordinates """ # return y*data.tileheight, x*data.tilewidth, l area = PlatformArea() parent.add(area) area.setParent(parent) area.mappath = res.mapPath(mapname) data = tmxloader.load_tmx(area.mappath) for gid, prop in data.tile_properties.items(): try: prop['guid'] = int(prop['guid']) except KeyError: pass props = data.getTilePropertiesByLayer(-1) """ print "GID MAP:" for k in sorted(data.gidmap.keys()): print " {}: {}\t{}".format(k, data.gidmap[k],