-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
106 lines (84 loc) · 2.9 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import sys
import pygame
from solipsist.GSS import GAME_NAME, SCREEN, WINDOW_HEIGHT, WINDOW_WIDTH, j
from solipsist.GSS import get_language
from solipsist.widget_loops.game import MUSIC, main
from solipsist.pygame_utils import Button
from solipsist.utils import resource_path
# Some imports are below, to prevent circular import
def main_menu():
_ = get_language()
pygame.display.set_caption(GAME_NAME)
pygame.init()
game_icon = pygame.image.load(resource_path("icon.png"))
pygame.display.set_icon(game_icon)
clock = pygame.time.Clock()
solipsist_button = Button(
"Solipsist",
(WINDOW_WIDTH / 2.5, WINDOW_HEIGHT / 10),
(WINDOW_WIDTH / 5, WINDOW_HEIGHT / 5),
)
start_button = Button(
_["main_menu.start"],
(WINDOW_WIDTH / 2.3, WINDOW_HEIGHT / 3),
(WINDOW_WIDTH / 10, WINDOW_HEIGHT / 15),
)
options_button = Button(
_["main_menu.options"],
(WINDOW_WIDTH / 2.3, WINDOW_HEIGHT / 2.4),
(WINDOW_WIDTH / 8, WINDOW_HEIGHT / 15),
)
stats_button = Button(
_["main_menu.stats"],
(WINDOW_WIDTH / 2.3, WINDOW_HEIGHT / 2),
(WINDOW_WIDTH / 10, WINDOW_HEIGHT / 15),
)
about_button = Button(
_["main_menu.about"],
(WINDOW_WIDTH / 2.3, WINDOW_HEIGHT / 1.70),
(WINDOW_WIDTH / 10, WINDOW_HEIGHT / 15),
)
quit_button = Button(
_["main_menu.quit"],
(WINDOW_WIDTH / 2.3, WINDOW_HEIGHT / 1.5),
(WINDOW_WIDTH / 10, WINDOW_HEIGHT / 15),
)
run = True
while run:
SCREEN.fill(j["graphic"]["BACKGROUND"][j["graphic"]["theme"]])
MUSIC.stop()
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
MUSIC.stop()
sys.exit()
if start_button.clicked(events):
MUSIC.sound_menu_click()
main()
if options_button.clicked(events):
MUSIC.sound_menu_click()
from solipsist.widget_loops.options import options
options()
if stats_button.clicked(events):
MUSIC.sound_menu_click()
from solipsist.widget_loops.stats import stats
stats()
if about_button.clicked(events):
MUSIC.sound_menu_click()
from solipsist.widget_loops.about import about
about()
if quit_button.clicked(events):
MUSIC.sound_menu_click()
sys.exit()
if solipsist_button.clicked(events):
pass # May add someting here, when player clicks logo
solipsist_button.draw_it(SCREEN)
start_button.draw_it(SCREEN)
options_button.draw_it(SCREEN)
stats_button.draw_it(SCREEN)
about_button.draw_it(SCREEN)
quit_button.draw_it(SCREEN)
pygame.display.flip()
clock.tick(j["game_settings"]["FPS"])
if __name__ == "__main__":
main_menu()