Game now knows the abs path of the program
This commit is contained in:
parent
c080816908
commit
479c6eece7
5
Run.py
5
Run.py
@ -1,3 +1,6 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from src.game.Game import Game
|
from src.game.Game import Game
|
||||||
|
|
||||||
game = Game()
|
programPath = Path(".").resolve()
|
||||||
|
game = Game(programPath)
|
||||||
|
@ -12,12 +12,12 @@ from src.game.Timer import Timer
|
|||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
def __init__(self):
|
def __init__(self, filesPath):
|
||||||
self.running = True
|
self.running = True
|
||||||
print("Loading configuration...", end=" ")
|
print("Loading configuration...", end=" ")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
configFolder = Path("../data/config/")
|
configFolder = Path(str(filesPath) + "/data/config/")
|
||||||
configFile = configFolder / "mainConfig.json"
|
configFile = configFolder / "mainConfig.json"
|
||||||
|
|
||||||
self.config = json.loads(configFile.read_text())
|
self.config = json.loads(configFile.read_text())
|
||||||
@ -47,8 +47,8 @@ class Game:
|
|||||||
self.screen = Screen(self, self.config["window"])
|
self.screen = Screen(self, self.config["window"])
|
||||||
print("OK")
|
print("OK")
|
||||||
|
|
||||||
self.mapDataFolder = path.dirname("../data/mapdata/")
|
mapFile = Path(str(filesPath) + "/data/mapdata/")
|
||||||
self.map = Map(path.join(self.mapDataFolder, 'map.txt'), self.screen)
|
self.map = Map(path.join(mapFile, 'map.txt'), self.screen)
|
||||||
self.player = Player((6, 2), self.map.tileSize)
|
self.player = Player((6, 2), self.map.tileSize)
|
||||||
self.map.addEntity(self.player)
|
self.map.addEntity(self.player)
|
||||||
self.eventManager = EventManager(self, self.player)
|
self.eventManager = EventManager(self, self.player)
|
||||||
|
Loading…
Reference in New Issue
Block a user