-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.py
65 lines (51 loc) · 1.71 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import pygame
from renderer import Renderer
from globaldata import FPS, rect_of_starting_button
from GUI import Button
clock = pygame.time.Clock()
class Menu():
'''
Loads menu and contains other methods.
'''
def __init__(self, screen):
self.renderer = Renderer(screen)
self.starting_button = Button("Начать", rect_of_starting_button)
def let_start(self, screen):
'''
Draws starting button.
Parameters
----------
screen : TYPE Pygame screen.
DESCRIPTION. Where everything is drawn.
Returns
-------
None.
'''
self.renderer.draw_button(screen, self.starting_button.name,
self.starting_button.location)
def load(self, screen):
'''
Suggests choosing settings if there are any. Then lets players start
playing.
Parameters
----------
screen : TYPE Pygame screen.
DESCRIPTION. Where everything is drawn.
Returns
-------
None.
'''
self.let_start(screen)
started = False
while not started:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
started = True
elif event.type == pygame.MOUSEBUTTONDOWN:
if ((event.button < 4) and
(self.starting_button.is_clicked(event.pos[0],
event.pos[1]))):
started = True
if __name__ == "__main__":
print("This module is not for direct call!")