def __init__(self, img, pos, tiler, maps, basepath): super(CycleMap, self).__init__(img, pos) self.maps = [] #self.tiler = weakref.proxy(tiler) self.tiler = tiler for i in maps: tmap = ReadMap(i) mapobj = tmap.parse(basepath) self.maps.append(mapobj) self.picked = 0
#self.images = self.assets.spider() game = Game() # quitter just waits for quit events quitter = Quitter() ### Keyboard listener/controler # example of myKBD listener # esc key pushes a quit event kbdman = myKBD() SharedObjects.setFlushColor((255,255,255)) #SharedObjects.setFlushColor((0,0,0)) #filepath = string.join(game.paths.assets + ["maps", "test_pathfinding.tmx"], os.path.sep) filepath = game.paths.assets + os.path.sep + "maps" + os.path.sep + "test_pathfinding.tmx" ## reading map data tmap = ReadMap(filepath) mapobj = tmap.parse(game.paths.assets) ## actual tiler- attaches to event and render manager s = mapobj.map.properties['spawn_player_at'] scale = SharedObjects.getScale() #x = s[0] * mapobj.map.tilewidth * scale #y = s[1] * mapobj.map.tileheight * scale #mx = (mapobj.map.width * scale/2) #- x #my = (mapobj.map.height * scale/2) #- y tiler = tilemap.TMXTiler(mapobj, (game.res[0], game.res[1]),(0,0)) path = os.path.sep.join([game.paths.assets, 'tiles','_no_ownership' , 'oryx_lofi_1.2' ,'oryx_lofi_1.1',]) #path = string.join(s, os.path.sep) art = ArtAssets(path) img = art.assets.retrieve("lofi_char_a", ((0, 0),(8, 8)) ) s = mapobj.map.properties['spawn_player_at'] player = Avatar(img, s, tiler) game.rendermanager.listeners.append(player)