Dec-24-2019, 11:27 AM
Merry Christmas too all of you out there.
I have a problem with pytmx, as you can already say from the title of this thread.
So I have made a class to load the map, that I made with the application "Tiled":
Merry Christmas.
I have a problem with pytmx, as you can already say from the title of this thread.
So I have made a class to load the map, that I made with the application "Tiled":
class TiledMap: def __init__(self, filename): tm = pytmx.load_pygame(filename, pixelalpha=True) self.width = tm.width * tm.tilewidth self.height = tm.height * tm.tileheight self.tmxdata = tm def render(self, surface): ti = self.tmxdata.get_tile_image_by_grid for layer in self.tmxdata.visible_layers: if isinstance(layer, pytmx.TiledTileLayer): for x, y, gid, in layer: tile = ti(gid) if tile: surface.blit(tile, (x * self.tmxdata.tilewidth, y * self.tmxdata.tileheight)) def make_map(self): temp_surface = pg.Surface((self.width, self.height)) self.render(temp_surface) return temp_surfaceI am loading it in the load section of my main.py file:
self.map = TiledMap(path.join(map_folder, 'outdoor.tmx')) self.map_img = self.map.make_map() self.map_rect = self.map_img.get_rect()But still I get this error:
Traceback (most recent call last): File "/Users/.../Desktop/MyRPG/main.py", line 5172, in <module> g = Game() File "/Users/.../Desktop/MyRPG/main.py", line 16, in __init__ self.load_data() File "/Users/.../Desktop/MyRPG/main.py", line 62, in load_data self.map = TiledMap(path.join(map_folder, 'outdoor.tmx')) File "/Users/.../Desktop/MyRPG/tilemap.py", line 22, in __init__ tm = pytmx.load_pygame(filename, pixelalpha=True) AttributeError: module 'pytmx.pytmx' has no attribute 'load_pygame'Any idea how to fix this?
Merry Christmas.