Entities load using abs path

This commit is contained in:
Marcin Kostrzewski 2020-04-06 12:31:44 +02:00
parent 89cf106432
commit 8f65ce87e2

View File

@ -24,12 +24,12 @@ class Entity(pygame.sprite.Sprite):
texturesFolder = "" texturesFolder = ""
textureFile = "" textureFile = ""
try: try:
texturesFolder = Path("../data/images/entities") texturesFolder = Path("./data/images/entities")
textureFile = texturesFolder / textureName textureFile = texturesFolder / textureName
except IOError: except IOError:
print("Cannot load texture from " + texturesFolder + ". Exiting...") print("Cannot load texture from " + texturesFolder + ". Exiting...")
exit(1) exit(1)
image = pygame.image.load(str(textureFile)).convert_alpha() image = pygame.image.load(str(textureFile.resolve())).convert_alpha()
image = pygame.transform.scale(image, (tileSize, tileSize)) image = pygame.transform.scale(image, (tileSize, tileSize))
rect = image.get_rect() rect = image.get_rect()
return image, rect return image, rect