-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrash.py
37 lines (31 loc) · 1.26 KB
/
crash.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
import pygame
from functions import *
from constants import *
# Crash Page
# ? Is it possible to combine this function with pause()
def crash(score):
if score > shelf['record']:
shelf['record'] = score
message('New Record!!', lobsterL, -50, blue)
pygame.draw.rect(display, white, (dispWD / 2, 3, dispWD / 2, 43))
record = lobsterS.render('Record: ' + str(shelf['record']), True, blue)
display.blit(record, record.get_rect(topright=(dispWD - 3, 3)))
else:
message('You Crashed', nosifer, -50, red)
restartRect, homeRect, quitRect = buttons()
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
end()
elif event.type == pygame.MOUSEBUTTONUP:
mouse = pygame.mouse.get_pos()
if restartRect.collidepoint(mouse):
return crashButton.restart
elif homeRect.collidepoint(mouse):
return crashButton.home
elif quitRect.collidepoint(mouse):
end()
elif event.type == pygame.KEYUP and event.key in [pygame.K_RETURN, pygame.K_SPACE]:
return crashButton.restart
clock.tick(10)