From 89cf10643230163cc0460187529634ac1b62b65c Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Mon, 6 Apr 2020 12:30:21 +0200 Subject: [PATCH] Loads tiles from file properly on all platforms --- src/game/TerrainTile.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/game/TerrainTile.py b/src/game/TerrainTile.py index 064c303..aaf8362 100644 --- a/src/game/TerrainTile.py +++ b/src/game/TerrainTile.py @@ -1,14 +1,13 @@ +from pathlib import Path + import pygame -import os -from os import path class TerrainTile(pygame.sprite.Sprite): def __init__(self, x, y, texture, tileSize): super().__init__() - self.imagesFolder = path.dirname("../data/images/") - self.terrainFolder = path.join(self.imagesFolder, 'terrain') - self.image = pygame.image.load(os.path.join(self.terrainFolder, texture)).convert() + terrainTexturesPath = Path("./data/images/terrain").resolve() + self.image = pygame.image.load(str(terrainTexturesPath / texture)).convert() self.image = pygame.transform.scale(self.image, (tileSize, tileSize)) self.rect = self.image.get_rect() self.x = x