I have made a map in the tiled editor and intend to use it in a game using pygame. I imported pytmx to help with this process but when I use load_pygame("directory of file") it give out this error
Traceback (most recent call last):
File "D:\Coder man\code\GUI\game map\showing map.py", line 7, in <module>
tmx_data = load_pygame("D:\Tile sheet\Dungeon Hub room.tmx")
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\util_pygame.py", line 183, in load_pygame
return pytmx.TiledMap(filename, *args, **kwargs)
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\pytmx.py", line 501, in __init__
self.parse_xml(ElementTree.parse(self.filename).getroot())
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\pytmx.py", line 550, in parse_xml
self.add_tileset(TiledTileset(self, subnode))
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\pytmx.py", line 1101, in __init__
self.parse_xml(node)
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\pytmx.py", line 1129, in parse_xml
source, self.parent.filename, path
Exception: Cannot find tileset file :/automap-tiles.tsx from D:\Tile sheet\Dungeon Hub room.tmx, should be at D:\Tile sheet\:\automap-tiles.tsx
the code I have so far is this:
import pygame, sys
from pytmx.util_pygame import load_pygame
pygame.init()
screen = pygame.display.set_mode((1280, 720))
tmx_data = load_pygame("D:\Tile sheet\Dungeon Hub room.tmx")
print(tmx_data)
# game loop
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
screen.fill("black")
pygame.display.update()
i was expecting the pygame to come up with no errors and an output of:
<Tiledmap: "Tile sheet\Dungeon Hub room.tmx">
and a pygame window
I have tried double checking the directory of the file and using pytmx.load_pygame