汇总路径
This commit is contained in:
parent
b639e5f5be
commit
3898dd920d
@ -9,10 +9,17 @@ else: # 非Windows系统存储路径
|
||||
USERDATA_PATH = os.path.expanduser(os.path.join("~", ".config", "wszqkzqk.dev", "pypvz", "userdata.json"))
|
||||
USERLOG_PATH = os.path.expanduser(os.path.join("~", ".config", "wszqkzqk.dev", "pypvz", "run.log"))
|
||||
|
||||
# 窗口图标
|
||||
ORIGINAL_LOGO = os.path.join(os.path.dirname(os.path.dirname(__file__)), "pypvz-exec-logo.png")
|
||||
# 僵尸显示特殊定义文件路径
|
||||
JSON_PATH_ZOMBIE = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'data', 'entity', 'zombie.json')
|
||||
# 植物显示特殊定义文件路径
|
||||
JSON_PATH_PLANTS = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'data', 'entity', 'plant.json')
|
||||
# 游戏图片资源路径
|
||||
IMG_DIR_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "resources","graphics")
|
||||
|
||||
# 窗口标题
|
||||
ORIGINAL_CAPTION = 'pypvz'
|
||||
# 窗口图标
|
||||
ORIGINAL_LOGO = "pypvz-exec-logo.png"
|
||||
|
||||
# 游戏模式
|
||||
GAME_MODE = 'mode'
|
||||
|
||||
@ -213,25 +213,21 @@ def load_all_gfx(directory, colorkey=c.WHITE, accept=('.png', '.jpg', '.bmp', '.
|
||||
# 从文件加载矩形碰撞范围
|
||||
# 用于消除文件边框影响
|
||||
def loadZombieImageRect():
|
||||
file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'data', 'entity', 'zombie.json')
|
||||
with open(file_path) as f:
|
||||
with open(c.JSON_PATH_ZOMBIE) as f:
|
||||
data = json.load(f)
|
||||
return data[c.ZOMBIE_IMAGE_RECT]
|
||||
|
||||
def loadPlantImageRect():
|
||||
file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'data', 'entity', 'plant.json')
|
||||
with open(file_path) as f:
|
||||
with open(c.JSON_PATH_PLANTS) as f:
|
||||
data = json.load(f)
|
||||
return data[c.PLANT_IMAGE_RECT]
|
||||
|
||||
pg.display.set_caption(c.ORIGINAL_CAPTION) # 设置标题
|
||||
SCREEN = pg.display.set_mode(c.SCREEN_SIZE) # 设置初始屏幕
|
||||
pg.mixer.set_num_channels(255) # 设置可以同时播放的音频数量,默认为8,经常不够用
|
||||
try: # 设置窗口图标,仅对非Nuitka时生效,Nuitka不需要包括额外的图标文件,自动跳过这一过程即可
|
||||
pg.display.set_icon(pg.image.load(os.path.join(os.path.dirname(os.path.dirname(__file__)), c.ORIGINAL_LOGO)))
|
||||
except:
|
||||
pass
|
||||
if os.path.exists(c.ORIGINAL_LOGO): # 设置窗口图标,仅对非Nuitka时生效,Nuitka不需要包括额外的图标文件,自动跳过这一过程即可
|
||||
pg.display.set_icon(pg.image.load(c.ORIGINAL_LOGO))
|
||||
|
||||
GFX = load_all_gfx(os.path.join(os.path.dirname(os.path.dirname(__file__)) ,os.path.join("resources","graphics")))
|
||||
GFX = load_all_gfx(c.IMG_DIR_PATH)
|
||||
ZOMBIE_RECT = loadZombieImageRect()
|
||||
PLANT_RECT = loadPlantImageRect()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user