-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildExe.py
64 lines (51 loc) · 2.86 KB
/
buildExe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import operator
import sys
import pygame2exe
import os
import shutil
__author__ = 'Donhilion'
DIST_FOLDER = "dist"
RESOURCES_FOLDER = "resources"
ANIMATION_FOLDER = "animations"
ANIMATION_FILES = ("animations.json",)
LEVEL_FOLDER = "levels"
LEVEL_FILES = ("level0.json",)
PICTURE_FOLDER = "pictures"
PICTURE_FILES = (
"background.png", "Coin.png", "goal.png", "grass.png", "Heart.png", "Hero.png", "HeroDie.png", "menuBackground.png",
"monster.png", "platform.png", "sparksis.png")
SETTING_FOLDER = "settings"
SETTING_FILES = ("graphics.json", "pictures.json", "sounds.json")
SOUND_FOLDER = "sounds"
SOUND_FILES = ("coin.wav", "hit.wav", "jump.wav", "music0.wav", "step.wav")
if __name__ == '__main__':
if operator.lt(len(sys.argv), 2):
sys.argv.append('py2exe')
pygame2exe.BuildExe().run()
if not os.path.exists(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER):
os.makedirs(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER)
if not os.path.exists(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + ANIMATION_FOLDER):
os.makedirs(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + ANIMATION_FOLDER)
for animation_file in ANIMATION_FILES:
shutil.copy(RESOURCES_FOLDER + os.path.sep + ANIMATION_FOLDER + os.path.sep + animation_file,
DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + ANIMATION_FOLDER)
if not os.path.exists(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + LEVEL_FOLDER):
os.makedirs(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + LEVEL_FOLDER)
for level_file in LEVEL_FILES:
shutil.copy(RESOURCES_FOLDER + os.path.sep + LEVEL_FOLDER + os.path.sep + level_file,
DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + LEVEL_FOLDER)
if not os.path.exists(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + PICTURE_FOLDER):
os.makedirs(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + PICTURE_FOLDER)
for picture_file in PICTURE_FILES:
shutil.copy(RESOURCES_FOLDER + os.path.sep + PICTURE_FOLDER + os.path.sep + picture_file,
DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + PICTURE_FOLDER)
if not os.path.exists(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + SETTING_FOLDER):
os.makedirs(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + SETTING_FOLDER)
for setting_file in SETTING_FILES:
shutil.copy(RESOURCES_FOLDER + os.path.sep + SETTING_FOLDER + os.path.sep + setting_file,
DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + SETTING_FOLDER)
if not os.path.exists(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + SOUND_FOLDER):
os.makedirs(DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + SOUND_FOLDER)
for sound_file in SOUND_FILES:
shutil.copy(RESOURCES_FOLDER + os.path.sep + SOUND_FOLDER + os.path.sep + sound_file,
DIST_FOLDER + os.path.sep + RESOURCES_FOLDER + os.path.sep + SOUND_FOLDER)