0

I´m trying to open a tmx map with this tmx library https://github.com/renfredxh/tmx/blob/master/tmx.py

My python code looks like this:

import tmx3
import random
import math 
import pygame
from socket import *
from pygame.locals import *
from random import randint


pygame.init()
screen = pygame.display.set_mode((1024,640))
tilemap = tmx3.load('map.tmx', screen.get_size()) 

The map.tmx i am trying to load, contains two layers. One tile layer without tile sets and one object layer with an rectangle.

I get the following error when trying to run my code:

Traceback (most recent call last):
  File "C:\Users\Samy\workspace\Traveler\src\implement.py", line 12, in <module>
    tilemap = tmx3.load('map.tmx', screen.get_size()) 
  File "C:\Users\Samy\workspace\Traveler\src\tmx3.py", line 848, in load
    return TileMap.load(filename, viewport)
  File "C:\Users\Samy\workspace\Traveler\src\tmx3.py", line 727, in load
    layer = Layer.fromxml(tag, tilemap)
  File "C:\Users\Samy\workspace\Traveler\src\tmx3.py", line 261, in fromxml
    data = decompress(b64decode(data)) 
zlib.error: Error -5 while decompressing data: incomplete or truncated stream

I printed data and the result was b''. Does anyone have a clue what is wrong here?

I found the same problem here but unanswered: Error using tmx with pygame

2 Answers2

0

I got the same error, when I was using a .tmx file in pure xml form. Tiled supports some different data-formats of the layer-data. (base64-uncompressed, base64-zlib, base64-gzip, csv and xml) It looks like this library expects the base64-zlib form.

Fusselgesicht
  • 189
  • 2
  • 6
0

It is the way you are doing it. These type of modules never seem to be very capable. I would try the csv method. I have used a text representation of tile map where as a w is like a brick and filled in the text file as I needed. It is the only way to do this that is why this question will never get answered. nobody has mad a deceit tmx module yet after 20 years