-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscores.py
More file actions
72 lines (60 loc) · 2.3 KB
/
scores.py
File metadata and controls
72 lines (60 loc) · 2.3 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
import pygame.font
from lives import Live
from pygame.sprite import Sprite, Group
import superpower
class Scores:
def __init__(self, screen, statistics, player_name):
self.screen = screen
self.screen_rect = screen.get_rect()
self.statistics = statistics
self.text_color = pygame.Color("red")
self.font = pygame.font.SysFont(None, 30)
self.player_name = player_name
self.image_score()
self.print_top_score()
self.print_lives()
def image_score(self):
self.score_image = self.font.render(
str(self.statistics.score),
True,
self.text_color,
pygame.Color("black"),
)
self.score_rect = self.score_image.get_rect()
self.score_rect.right = self.screen_rect.right - 40
self.score_rect.top = 20
def print_top_score(self):
self.top_score_image = self.font.render(
str(self.statistics.top_score),
True,
self.text_color,
pygame.Color("black"),
)
self.top_score_rect = self.top_score_image.get_rect()
self.top_score_rect.centerx = self.screen_rect.centerx
self.top_score_rect.top = self.screen_rect.top + 20
def print_lives(self):
self.lives = Group()
for live_number in range(self.statistics.lives):
live = Live(self.screen)
live.rect.x = 15 + live_number * live.rect.width
live.rect.y = 20
self.lives.add(live)
def print(self):
self.screen.blit(self.score_image, self.score_rect)
self.screen.blit(self.top_score_image, self.top_score_rect)
for live in self.lives:
live.print_live()
def print_superpower(self, gun):
smth_live = Live(self.screen)
power = None
if (gun.freeze):
power = superpower.Freeze(self.screen, smth_live)
if (gun.machine_gun):
power = superpower.MachineGun(self.screen, smth_live)
if (gun.invincibility):
power = superpower.Invincibility(self.screen, smth_live)
if (gun.freeze or gun.machine_gun or gun.invincibility):
power.rect.x = 15
power.rect.y = 50
power.print()