适配单文件发布
This commit is contained in:
parent
82f3a22c0e
commit
20decabf8f
@ -2,7 +2,7 @@ __author__ = 'wszqkzqk'
|
|||||||
|
|
||||||
START_LEVEL_NUM = 1
|
START_LEVEL_NUM = 1
|
||||||
|
|
||||||
ORIGINAL_CAPTION = 'Plant VS Zombies Game'
|
ORIGINAL_CAPTION = 'pypvz'
|
||||||
|
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 600
|
SCREEN_HEIGHT = 600
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class Level(tool.State):
|
|||||||
|
|
||||||
def loadMap(self):
|
def loadMap(self):
|
||||||
map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json'
|
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)
|
f = open(file_path)
|
||||||
self.map_data = json.load(f)
|
self.map_data = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
@ -155,14 +155,14 @@ def load_all_gfx(directory, colorkey=c.WHITE, accept=('.png', '.jpg', '.bmp', '.
|
|||||||
return graphics
|
return graphics
|
||||||
|
|
||||||
def loadZombieImageRect():
|
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)
|
f = open(file_path)
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
return data[c.ZOMBIE_IMAGE_RECT]
|
return data[c.ZOMBIE_IMAGE_RECT]
|
||||||
|
|
||||||
def loadPlantImageRect():
|
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)
|
f = open(file_path)
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
@ -172,6 +172,6 @@ pg.init()
|
|||||||
pg.display.set_caption(c.ORIGINAL_CAPTION)
|
pg.display.set_caption(c.ORIGINAL_CAPTION)
|
||||||
SCREEN = pg.display.set_mode(c.SCREEN_SIZE)
|
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()
|
ZOMBIE_RECT = loadZombieImageRect()
|
||||||
PLANT_RECT = loadPlantImageRect()
|
PLANT_RECT = loadPlantImageRect()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user