-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.py
42 lines (42 loc) · 1.39 KB
/
menu.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
"""Import modules"""
from functions import get_pos_mouse, hover
from variables import (
screen,
stats_button,
timer_button,
menu_image,
end_button,
json,
data,
width,
pygame,
)
from stats import stats
from timer import timer
def main_menu():
"""main menu"""
playing = True
while playing:
screen.fill((255,255,255))
#pos mouse
pos_x, pos_y = get_pos_mouse()
hover(pos_x, pos_y)
for event in pygame.event.get():
if event.type == 256:
playing = False
elif event.type == 1025 and event.button == 1 :
#lauching the right page
if end_button.check_mouse(pos_x, pos_y):
playing = False
elif stats_button.check_mouse(pos_x, pos_y):
stats(True)
elif timer_button.check_mouse(pos_x, pos_y):
timer(True)
with open("data.json", "w", encoding="utf-8") as file:
json.dump(data, file, indent=4)
stats_button.display()
timer_button.display()
end_button.display()
screen.blit(menu_image, (width / 2 - 300 / 2, 100))
pygame.display.flip()
pygame.display.quit()