Feb-01-2020, 11:22 AM
Hello everybody,
I know, I have posted a bit different question a few months ago. Now that I can load my Map with pytmx, I have troubles displaying an isometric map with pytmx.
I am creating a game using the language python. For the game map, I have downloaded the "Tiled" Map Editor, which I used to make an isometric map. Now I wanted to load this isometric map into my python script using the python library "pytmx", which can read tmx map files. I searched through the whole internet, but I didn't found out, how to display an isometric map in python. What I've done, is trying to load the isometric map, with a script that is supposed to load orthodox maps (2D maps, top down). Of course, I could load the isometric map with it, but it looks stupid, cause it is not being displayed in an isometric perspective. So that's why it looks pretty stupid.
So here is the code, I have been using, to load the map:
Thank you so much for your help,
Piethon
I know, I have posted a bit different question a few months ago. Now that I can load my Map with pytmx, I have troubles displaying an isometric map with pytmx.
I am creating a game using the language python. For the game map, I have downloaded the "Tiled" Map Editor, which I used to make an isometric map. Now I wanted to load this isometric map into my python script using the python library "pytmx", which can read tmx map files. I searched through the whole internet, but I didn't found out, how to display an isometric map in python. What I've done, is trying to load the isometric map, with a script that is supposed to load orthodox maps (2D maps, top down). Of course, I could load the isometric map with it, but it looks stupid, cause it is not being displayed in an isometric perspective. So that's why it looks pretty stupid.
So here is the code, I have been using, to load the map:
import pygame as pg import pytmx from settings import * 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_gid 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_surfaceSo now my question: How do I need to transform that code above, that it is able to display isometric maps right?
Thank you so much for your help,
Piethon