-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResultScreen.py
96 lines (75 loc) · 3.65 KB
/
ResultScreen.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
from GameParameter import display
from GameEffects import drawing_text, load_image
from Button import Button
import sqlite3
import datetime as dt
background = load_image('result_background.png')
back_button_image = [load_image(f'pause_back_{i}.png') for i in range(2)]
restart_button_image = [load_image(f'pause_restart_{i}.png') for i in range(2)]
miss = load_image('skin/hit0.png')
bad = load_image('skin/hit50.png')
good = load_image('skin/hit100.png')
great = load_image('skin/hit200.png')
perfect = load_image('skin/hit300.png')
marvelous = load_image('skin/hit300g.png')
class ResultScreen:
def __init__(self, count_combo, score, marks, accuracy, map):
self.result = -1
self.count_combo = str(count_combo) + 'x'
self.score = str(score)
self.marks = [str(i) + 'x' for i in marks.values()]
if accuracy == 100:
self.rank = load_image('skin/rank_SS.png')
elif accuracy > 95:
self.rank = load_image('skin/rank_S.png')
elif accuracy > 90:
self.rank = load_image('skin/rank_A.png')
elif accuracy > 80:
self.rank = load_image('skin/rank_B.png')
elif accuracy > 70:
self.rank = load_image('skin/rank_C.png')
else:
self.rank = load_image('skin/rank_D.png')
self.accuracy = str('%.2f' % accuracy) + '%'
self.back_btn = Button(-30, 630, 236, 92, '', back_button_image, self.back)
self.restart_btn = Button(908, 630, 236, 92, '', restart_button_image, self.restart)
map_id = map[2].map_id
mapset_id = map[2].mapset_id
time = str(dt.datetime.now().time()).split('.')[0]
date = str(dt.datetime.now().date())
con = sqlite3.connect('records.db')
cur = con.cursor()
cur.execute(
f"INSERT INTO Records(map_id, mapset_id, score, accuracy, combo, date, time) VALUES({map_id}, {mapset_id}, {score}, {accuracy}, {count_combo}, '{date}', '{time}')")
con.commit()
def render(self):
display.blit(background, (0, 0))
display.blit(self.rank, (775, 110))
# отрисовка точности игрока
drawing_text(self.accuracy, (790, 400), (255, 255, 255), 60, font_type='corp_round_v1.ttf')
display.blit(miss, (0, 40))
drawing_text(self.marks[0], (65, 100), (200, 0, 0), 50, font_type='corp_round_v1.ttf')
# отрисовка набранных оценок
display.blit(bad, (290, 40))
drawing_text(self.marks[1], (355, 100), (230, 0, 150), 50, font_type='corp_round_v1.ttf')
display.blit(good, (0, 170))
drawing_text(self.marks[2], (65, 230), (0, 185, 230), 50, font_type='corp_round_v1.ttf')
display.blit(great, (290, 170))
drawing_text(self.marks[3], (355, 230), (0, 230, 30), 50, font_type='corp_round_v1.ttf')
display.blit(perfect, (0, 320))
drawing_text(self.marks[4], (65, 390), (255, 255, 75), 50, font_type='corp_round_v1.ttf')
display.blit(marvelous, (290, 315))
drawing_text(self.marks[5], (355, 390), (235, 250, 255), 50, font_type='corp_round_v1.ttf')
# отрисовка максимального комбо игрока
drawing_text(self.count_combo, (210, 520), (255, 255, 255), 50, font_type='corp_round_v1.ttf')
score_width = len(self.score) * 25
x = 890 - score_width // 2
drawing_text(self.score, (x, 530), (255, 255, 255), 50, font_type='corp_round_v1.ttf')
self.back_btn.draw(0, 0)
self.restart_btn.draw(0, 0)
def get_result(self):
return self.result
def back(self):
self.result = 0
def restart(self):
self.result = 1