From 20decabf8fbead81bf26b1351d9c04e8c7db8235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Thu, 31 Mar 2022 21:10:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=8D=95=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/constants.py | 2 +- source/state/level.py | 2 +- source/tool.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/constants.py b/source/constants.py index 8a44cc3..7cb404d 100755 --- a/source/constants.py +++ b/source/constants.py @@ -2,7 +2,7 @@ __author__ = 'wszqkzqk' START_LEVEL_NUM = 1 -ORIGINAL_CAPTION = 'Plant VS Zombies Game' +ORIGINAL_CAPTION = 'pypvz' SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 diff --git a/source/state/level.py b/source/state/level.py index bd0356f..b7fbb3e 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -25,7 +25,7 @@ class Level(tool.State): def loadMap(self): map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json' - file_path = os.path.join(sys.path[0], 'source', 'data', 'map', map_file) + file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'source', 'data', 'map', map_file) f = open(file_path) self.map_data = json.load(f) f.close() diff --git a/source/tool.py b/source/tool.py index 2ebc9f6..a3f5e33 100755 --- a/source/tool.py +++ b/source/tool.py @@ -155,14 +155,14 @@ def load_all_gfx(directory, colorkey=c.WHITE, accept=('.png', '.jpg', '.bmp', '. return graphics def loadZombieImageRect(): - file_path = os.path.join(sys.path[0], 'source', 'data', 'entity', 'zombie.json') + file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'source', 'data', 'entity', 'zombie.json') f = open(file_path) data = json.load(f) f.close() return data[c.ZOMBIE_IMAGE_RECT] def loadPlantImageRect(): - file_path = os.path.join(sys.path[0], 'source', 'data', 'entity', 'plant.json') + file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'source', 'data', 'entity', 'plant.json') f = open(file_path) data = json.load(f) f.close() @@ -172,6 +172,6 @@ pg.init() pg.display.set_caption(c.ORIGINAL_CAPTION) SCREEN = pg.display.set_mode(c.SCREEN_SIZE) -GFX = load_all_gfx(os.path.join(sys.path[0] ,os.path.join("resources","graphics"))) +GFX = load_all_gfx(os.path.join(os.path.dirname(os.path.dirname(__file__)) ,os.path.join("resources","graphics"))) ZOMBIE_RECT = loadZombieImageRect() PLANT_RECT = loadPlantImageRect()