上传文件至 ''

This commit is contained in:
206530221 2021-06-22 12:35:04 +08:00
parent f6a25876e7
commit 65630fe80f
1 changed files with 11 additions and 0 deletions

View File

@ -24,3 +24,14 @@ class Scoreboard():
self.prep_level()
self.prep_ships()
def prep_score(self):
"""将得分转换为一幅渲染的图像"""
rounded_score = int(round(self.stats.score, -1))
score_str = "{:,}".format(rounded_score)
self.score_image = self.font.render(score_str, True, self.text_color,
self.ai_settings.bg_color)
# 将得分放在屏幕右上角
self.score_rect = self.score_image.get_rect()
self.score_rect.right = self.screen_rect.right - 20
self.score_rect.top = 20