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?
#19
...and once I actually woke up, I realized all that math can be based entirely off the indices, instead of having temporary variables. And also, that the tiles needed to be rotated 45 degrees:
    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:
                    x_offset = (WIDTH / 2) + (self.tmxdata.tilewidth / 2 * (x+1)) - (self.tmxdata.tilewidth / 2 * (y+1))
                    y_offset = ((y+1) * self.tmxdata.tileheight) + (self.tmxdata.tileheight * x)

                    tile = ti(gid)
                    if tile:
                        rotated = pg.transform.rotate(tile.convert_alpha(), 45)
                        surface.blit(rotated, (x_offset, y_offset))
mattwins likes this post
Reply


Messages In This Thread
RE: How to display isometric maps with pytmx? - by nilamo - Feb-19-2020, 04:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Isometric game pygame Tiled howardberger 1 615 Jan-31-2024, 10:01 PM
Last Post: deanhystad
  [PyGame] Isometric Movement on Tiled Map Josselin 0 2,374 Nov-02-2021, 06:56 AM
Last Post: Josselin
Thumbs Up [PyGame] Simple code for isometric 2D games ThePhi 1 15,313 Nov-17-2020, 12:58 PM
Last Post: mattwins
  [split] How to display isometric maps with pygame? mattwins 6 6,273 Nov-17-2020, 12:54 PM
Last Post: mattwins
  Problems with pytmx Piethon 15 9,402 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