I made a small piece of the map and was able to open it when the absolute path was indicated, I tried to put … before the path in the files, as I understand it, the working directory is indicated, but nothing works.
the directory looks like this:
main.py
background.py
map —>
Field.tmx
Forest.tsx
Tree 1.tsx
Tree 1.png
gentle forest (size 48x48) v01.png
background.py:
from pathlib import Path
from pytmx.util_pygame import load_pygame
class Background:
def __init__(self, filename, x=0, y=0):
self.map = Path('map', filename)
self.x = x
self.y = y
def draw(self, camera, screen):
map_data = load_pygame(self.map)
for layer in map_data:
for tile in layer.tiles():
x_pixel = tile[0] * 48 + self.x
y_pixel = tile[1] * 48 + self.y
screen.blit(tile[2], (-camera.rect[0] + x_pixel, -camera.rect[1] + y_pixel))
As soon as I didn’t try to write the path in the files, please help)