-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainMenu.py
More file actions
104 lines (89 loc) · 3.36 KB
/
Copy pathmainMenu.py
File metadata and controls
104 lines (89 loc) · 3.36 KB
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
# main menu class
import pygame
import button
import textTitle
import textDisplay
import util
class MainMenu():
def __init__(self, screen, clock, height, width):
self.screen = screen
self.clock = clock
self.height = height
self.width = width
self.background_input = pygame.image.load(util.resourcePath(
'images/space_background.jpeg')).convert()
self.background = pygame.transform.smoothscale(
self.background_input, (self.width, self.height))
self.numPlayers = 0
# main menu
def getInput(self):
# initializing sounds
pygame.mixer.init()
selection = pygame.mixer.Sound(
util.resourcePath('sounds/selection.mp3'))
text = textTitle.TextTitle("Wheel of Jeopardy", self.width/2, 200)
subtitle = textDisplay.TextDisplay(
"Created by The ByteMe Team", 16, self.width/2, 250)
# self.screen.blit(self.background, (0, 0))
# pygame.display.update()
# player number entry text
playerNumText = textDisplay.TextDisplay(
"Select Number of Players", 48, self.width/2, self.height/2 - 105)
# buttons
# start_button = button.Button(
# "START", 36, self.width/2, self.height/2)
exit_button = button.Button(
"EXIT", 36, self.width/2, self.height/2 + 200)
# player number entry buttons
playerNum_2 = button.Button(
"2", 36, self.width/2 - 75, self.height/1.8)
playerNum_3 = button.Button(
"3", 36, self.width//2 - 25, self.height/1.8)
playerNum_4 = button.Button(
"4", 36, self.width//2 + 25, self.height/1.8)
playerNum_5 = button.Button(
"5", 36, self.width//2 + 75, self.height/1.8)
while True:
# draw elements
self.screen.blit(self.background, (0, 0))
# start_button.draw(self.screen)
exit_button.draw(self.screen)
text.draw(self.screen)
subtitle.draw(self.screen)
playerNum_2.draw(self.screen)
playerNum_3.draw(self.screen)
playerNum_4.draw(self.screen)
playerNum_5.draw(self.screen)
playerNumText.draw(self.screen)
# event handlers
for event in pygame.event.get():
# game window handlers
if event.type == pygame.QUIT:
pygame.quit()
exit()
# if start_button.clicked:
# return True
if exit_button.clicked:
pygame.quit()
exit()
if playerNum_2.clicked:
self.numPlayers = 2
selection.play()
return True
if playerNum_3.clicked:
self.numPlayers = 3
selection.play()
return True
if playerNum_4.clicked:
self.numPlayers = 4
selection.play()
return True
if playerNum_5.clicked:
self.numPlayers = 5
selection.play()
return True
# other handlers
# ...
# update the game state
pygame.display.update()
self.clock.tick(60)