-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathendScreen.py
More file actions
111 lines (94 loc) · 3.56 KB
/
Copy pathendScreen.py
File metadata and controls
111 lines (94 loc) · 3.56 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
105
106
107
108
109
110
111
# end screen class
import pygame
import button
import textMedium
import textDisplay
import util
class EndScreen():
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.playerList = []
# main menu
def getInput(self, numPlayers, playerList, finalScores):
# initalizing sounds
pygame.mixer.init()
selection = pygame.mixer.Sound(
util.resourcePath('sounds/selection.mp3'))
text = textMedium.TextMedium(
"Thank you for Playing!", self.width/2, self.height/2 - 300)
# self.screen.blit(self.background, (0, 0))
playerScoreIntro = textDisplay.TextDisplay(
"Final player scores:", 26, self.width/2, self.height/2 - 200)
# determining winner
print("[LOG]: " + str(len(finalScores)))
winner = 0
for x in range(1, len(finalScores)):
if (finalScores[winner] == finalScores[x]):
winner = 7
break
if (finalScores[winner] < finalScores[x]):
winner = x
if (winner == 7):
winnerText = textMedium.TextMedium(
"It's a tie!", self.width/2, self.height/2 + 250)
else:
winnerText = textMedium.TextMedium(
"The winner is " + playerList[winner] + "!", self.width/2, self.height/2 + 250)
nameTextArray = []
scoreTextArray = []
for x in range(numPlayers):
nameTextArray.append(textDisplay.TextDisplay(
playerList[x] + ":", 26, self.width/2 - 90, self.height - 550 + 70*x))
scoreTextArray.append(textDisplay.TextDisplay(
str(finalScores[x]), 26, self.width/2 + 100, self.height - 550 + 70*x))
# buttons
continue_button = button.Button(
"MAIN MENU", 32, self.width*(1 - 1/8), self.height - 50)
# draw first elements
self.screen.blit(self.background, (0, 0))
continue_button.draw(self.screen)
text.draw(self.screen)
playerScoreIntro.draw(self.screen)
# draw player names/scores
for x in nameTextArray:
x.draw(self.screen)
for x in scoreTextArray:
x.draw(self.screen)
# initializing drumroll
m = pygame.mixer.music
m.load(util.resourcePath('sounds/drumroll.wav'))
m.play()
m.set_volume(1)
pygame.display.update()
pygame.event.pump()
# cue next music
m.queue(util.resourcePath('sounds/uplifting.mp3'))
# wait for drumroll before displaying winner
pygame.time.wait(5500)
#self.screen.blit(self.background, (0, 0))
winnerText.draw(self.screen)
pygame.time.wait(500)
loop = True
while loop:
continue_button.draw(self.screen)
# event handlers
for event in pygame.event.get():
# game window handlers
if event.type == pygame.QUIT:
pygame.quit()
exit()
if continue_button.clicked:
selection.play()
return
# other handlers
# ...
# update the game state
pygame.display.update()
self.clock.tick(60)