-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinalscreen.py
120 lines (72 loc) · 2.89 KB
/
finalscreen.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
import pygame
import sys
def main(correct_ans):
pygame.init()
WIDTH, HEIGHT = 1400, 800
screen = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
pygame.display.set_caption("Final Screen")
pygame.mixer.music.load('assets/music/menu.mp3')
pygame.mixer.music.play(0)
class Button():
def __init__(self, x, y, image, scale):
width = image.get_width()
height = image.get_height()
self.image = pygame.transform.scale(image, (int(width * scale), int(height * scale)))
self.rect = self.image.get_rect()
self.rect.topleft = (x, y)
self.clicked = False
def click(self, surface):
action = False
#get mouse position
pos = pygame.mouse.get_pos()
#check mouseover and clicked conditions
if self.rect.collidepoint(pos):
if pygame.mouse.get_pressed()[0] == 1 and self.clicked == False:
self.clicked = True
action = True
if pygame.mouse.get_pressed()[0] == 0:
self.clicked = False
#draw button on screen
surface.blit(self.image, (self.rect.x, self.rect.y))
return action
bg1 = pygame.image.load('assets/title/finalbg.png')
#linear algebruh
img_1 = pygame.image.load('assets/title/menu.png').convert_alpha()
button1 = Button(510, 420, img_1, 1)
img_2 = pygame.image.load('assets/title/info.png').convert_alpha()
button2 = Button(510, 520, img_2, 1)
img_3 = pygame.image.load('assets/title/quit.png').convert_alpha()
button3 = Button(510, 620, img_3, 1)
newans = correct_ans
res = 4 - newans
font = pygame.font.SysFont("comicsansms",40)
text = font.render(f"CONGRATULATIONS, YOU HAVE {res} RESTAKE!", True, (255,255,255))
rect = text.get_rect()
rect.center = (WIDTH // 2, 40)
done = False
while not done:
pygame.time.wait(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
screen.blit(bg1, (0,0))
if button1.click(screen):
import titlescreen
titlescreen.main()
if button2.click(screen):
import infoscreen
infoscreen.main()
if button3.click(screen):
done = True
if res == 1:
text = font.render(f"CONGRATULATIONS, YOU HAVE {res} RETAKE!", True, (255,255,255))
else:
text = font.render(f"CONGRATULATIONS, YOU HAVE {res} RETAKES!", True, (255,255,255))
screen.blit(text, rect)
pygame.display.flip()
clock.tick(60)
pygame.quit()
sys.exit()
if __name__ == "__main__":
main()