forked from KendallDoesCoding/Choose-Your-Own-Adventure-Game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
69 lines (51 loc) · 1.66 KB
/
main.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
65
66
67
68
69
# import modules
import subprocess
import sys
# Set the taskbar icon to same as pygame window icon
import ctypes
myappid = 'KendallDoesCoding.ChooseYourAdventureGame.1.0' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
import os
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide"
import pkg_resources
from chapters import *
import music_player
from GUI.GUI import GUIInstance
# install missing modules
required = {"colorama==0.4.6", "pygame==2.2.0"}
installed = {pkg.key for pkg in pkg_resources.working_set}
if missing := required - installed:
python = sys.executable
subprocess.check_call([python, "-m", "pip", "install", *missing],
stdout=subprocess.DEVNULL)
# import dependencies
import pygame
pygame.init()
# heading text!
heading = "Choose Your Own Adventure Game!"
copyright = "\U000000A9 2023, KendallDoesCoding, All Rights Reserved"
new_str = Fore.BLUE + heading.center(150)
new_str2 = Fore.BLUE + copyright.center(150)
print(new_str)
print(new_str2)
SCR_W = 800
SCR_H = 600
RUN_GUI = True
try:
WINDOW = pygame.display.set_mode((SCR_W, SCR_H))
print(Fore.RED + "Game opened with Pygame!")
except Exception as e:
RUN_GUI = False
print(Fore.RED + "Running without pygame")
pygame.display.set_caption("Choose Your Own Adventure")
pygame.display.set_icon(pygame.image.load("assets/images/logo.png")) # SET PYGAME WINDOW ICON
def main():
if RUN_GUI:
GUIInstance.set_params(SCR_W, SCR_H, WINDOW)
music_player.music()
else:
GUIInstance.set_params_no_gui()
GUIInstance.start_screen()
random.choice(my_list)()
if __name__ == "__main__":
main()