Python Forum
How to display isometric maps with pytmx?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to display isometric maps with pytmx?
#1
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:
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_surface
So 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
Reply


Messages In This Thread
How to display isometric maps with pytmx? - by Piethon - Feb-01-2020, 11:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Isometric game pygame Tiled howardberger 1 649 Jan-31-2024, 10:01 PM
Last Post: deanhystad
  [PyGame] Isometric Movement on Tiled Map Josselin 0 2,394 Nov-02-2021, 06:56 AM
Last Post: Josselin
Thumbs Up [PyGame] Simple code for isometric 2D games ThePhi 1 15,369 Nov-17-2020, 12:58 PM
Last Post: mattwins
  [split] How to display isometric maps with pygame? mattwins 6 6,346 Nov-17-2020, 12:54 PM
Last Post: mattwins
  Problems with pytmx Piethon 15 9,529 Jan-05-2020, 10:44 AM
Last Post: Piethon

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020