-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.py
189 lines (162 loc) · 7.68 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import pygame
class Menu:
def __init__(self, game):
self.game = game
self.x, self.y = self.game.display.get_size()
self.mid_w, self.mid_h = self.x / 2, self.y / 2
self.run_display = True
self.offset = -100
def draw_cross(self):
for y_offset in range(0, 100, 10):
pygame.draw.line(self.game.display, self.game.RED,
[0, 0 + y_offset], [self.x, self.y + y_offset], 2)
pygame.draw.line(self.game.display, self.game.RED,
[0, self.y + y_offset], [self.x, 0 + y_offset], 2)
# pygame.draw.polygon(self.game.display, self.game.RED,
# [[self.mid_w, self.mid_h], [340, 345], [400, 390], [460, 345]], 0)
class MainMenu(Menu):
def __init__(self, game):
Menu.__init__(self, game)
self.state = 'Start'
self.startx, self.starty = self.mid_w, self.mid_h + 200
self.optionsx, self.optionsy = self.mid_w, self.mid_h + 225
self.creditsx, self.creditsy = self.mid_w, self.mid_h + 250
self.exitx, self.exity = self.mid_w, self.mid_h + 275
self.prect = pygame.Rect(self.startx - 25, self.starty - 5, 100, 10)
self.orect = pygame.Rect(self.optionsx - 25, self.optionsy - 5, 100, 10)
self.crect = pygame.Rect(self.creditsx - 25, self.creditsy - 5, 100, 10)
self.erect = pygame.Rect(self.exitx - 25, self.exity - 5, 100, 10)
def display_menu(self):
self.run_display = True
while self.run_display:
self.game.check_events()
self.check_input()
self.game.display.fill(self.game.BLACK)
# double quotes for use of apostrophe
self.game.draw_text("Troller's Paradise", 30, self.mid_w, self.mid_h - 250)
self.game.draw_text('Start Game', 20, self.startx, self.starty)
self.game.draw_text('Options', 20, self.optionsx, self.optionsy)
self.game.draw_text('Credits', 20, self.creditsx, self.creditsy)
self.game.draw_text('Exit', 20, self.exitx, self.exity)
self.draw_cross()
self.game.blit_screen()
def check_input(self):
self.pos = pygame.mouse.get_pos()
if self.game.click:
if self.prect.collidepoint(self.pos):
import chess
self.run_display = False
chess.Chess()
elif self.orect.collidepoint(self.pos):
self.game.curr_menu = self.game.options
elif self.crect.collidepoint(self.pos):
self.game.curr_menu = self.game.credits
elif self.erect.collidepoint(self.pos):
pygame.quit()
self.run_display = False
class OptionsMenu(Menu):
def __init__(self, game):
Menu.__init__(self, game)
self.state = 'Volume'
self.volx, self.voly = self.mid_w, self.mid_h + 200
self.controlsx, self.controlsy = self.mid_w, self.mid_h + 225
self.backx, self.backy = self.mid_w, self.mid_h + 250
self.vrect = pygame.Rect(self.volx - 25, self.voly - 5, 100, 10)
self.crect = pygame.Rect(self.controlsx - 25, self.controlsy - 5, 100, 10)
self.brect = pygame.Rect(self.backx - 25, self.backy - 5, 100, 10)
def display_menu(self):
self.run_display = True
while self.run_display:
self.game.check_events()
self.check_input()
self.game.display.fill((0, 0, 0))
self.game.draw_text('Options', 30, self.mid_w, self.mid_h - 200)
self.game.draw_text('Volume', 20, self.volx, self.voly)
self.game.draw_text('Controls', 20, self.controlsx, self.controlsy)
self.game.draw_text('Back', 20, self.backx, self.backy)
self.draw_cross()
self.game.blit_screen()
def check_input(self):
self.pos = pygame.mouse.get_pos()
if self.game.click:
if self.vrect.collidepoint(self.pos):
self.game.curr_menu = self.game.volume_menu
elif self.crect.collidepoint(self.pos):
self.game.curr_menu = self.game.controls_menu
elif self.brect.collidepoint(self.pos):
self.game.curr_menu = self.game.main_menu
self.run_display = False
self.run_display = False
class VolumeMenu(Menu):
def __init__(self, game):
Menu.__init__(self, game)
self.volx, self.voly = self.mid_w, self.mid_h + 225
self.controlsx, self.controlsy = self.mid_w, self.mid_h + 250
self.backx, self.backy = self.mid_w, self.mid_h + 275
self.mrect = pygame.Rect(self.volx - 25, self.voly - 5, 100, 10)
self.srect = pygame.Rect(self.controlsx - 25, self.controlsy - 5, 100, 10)
self.brect = pygame.Rect(self.backx - 25, self.backy - 5, 100, 10)
def display_menu(self):
self.run_display = True
while self.run_display:
self.game.check_events()
self.check_input()
self.game.display.fill((0, 0, 0))
self.game.draw_text('Volume', 30, self.mid_w, self.mid_h - 200)
self.game.draw_text(f'Music:{self.game.mute1}', 20, self.volx, self.voly)
self.game.draw_text(f'Sound:{self.game.mute2}', 20, self.controlsx, self.controlsy)
self.game.draw_text('Back', 20, self.backx, self.backy)
self.draw_cross()
self.game.blit_screen()
def check_input(self):
self.pos = pygame.mouse.get_pos()
if self.game.click:
if self.mrect.collidepoint(self.pos) and self.game.mute1 == 'Off':
pygame.mixer.music.unpause()
self.game.mute1 = 'On'
elif self.mrect.collidepoint(self.pos) and self.game.mute1 == 'On':
pygame.mixer.music.pause()
self.game.mute1 = 'Off'
elif self.srect.collidepoint(self.pos) and self.game.mute2 == 'Off':
self.game.mute2 = 'On'
elif self.srect.collidepoint(self.pos) and self.game.mute2 == 'On':
self.game.mute2 = 'Off'
elif self.brect.collidepoint(self.pos):
self.game.curr_menu = self.game.options
self.run_display = False
class ControlsMenu(Menu):
def __init__(self, game):
Menu.__init__(self, game)
self.volx, self.voly = self.mid_w, self.mid_h + 200
def display_menu(self):
self.run_display = True
while self.run_display:
self.game.check_events()
self.check_input()
self.game.display.fill((0, 0, 0))
self.game.draw_text('Controls', 30, self.mid_w, self.mid_h - 200)
self.game.draw_text('Mouse', 20, self.volx, self.voly)
self.draw_cross()
self.game.blit_screen()
def check_input(self):
if self.game.click:
self.game.curr_menu = self.game.options
self.run_display = False
class CreditsMenu(Menu):
def __init__(self, game):
Menu.__init__(self, game)
def display_menu(self):
self.run_display = True
while self.run_display:
self.game.check_events()
if self.game.click:
self.game.curr_menu = self.game.main_menu
self.run_display = False
self.game.display.fill(self.game.BLACK)
self.game.draw_text('Credits', 40, self.mid_w, self.mid_h - 200)
self.game.draw_text('Made by Deathboard Productions', 25, self.mid_w, self.mid_h - 100)
self.game.draw_text('Lead Developer, Graphics Designer, Sound Engineer:', 15, self.mid_w, self.mid_h + 25)
self.game.draw_text('Troller AKA Cole', 25, self.mid_w, self.mid_h + 50)
self.game.blit_screen()
pygame.display.quit()
pygame.quit()