# 初始分数
score = 0
# 显示评分功能
def show_score(choice, color, font, size):
# 创建字体对象 score_font
score_font = pygame.font.SysFont(font, size)
# 创建显示表面对象 score_surface
score_surface = score_font.render('Score :' + str(score), True, color)
# 为文本表面对象创建一个矩形对象
score_rect = score_surface.get_rect()
# 显示文字
game_window.blit(score_surface, score_rect)
# 游戏结束功能
def game_over():
# 创建字体对象 my_font
my_font = pygame.font.SysFont('times new roman', 50)
# 创建将在其上绘制文本的文本表面
game_over_surface = my_font.render('Your Score is :' + str(score), True, red)
# 为文本表面对象创建一个矩形对象
game_over_rect = game_over_surface.get_rect()
# 设置文本位置
game_over_rect.midtop = (window_x / 2, window_y / 4)
# blit 将在屏幕上绘制文本
game_window.blit(game_over_surface, game_over_rect)
pygame.display.flip()
# 2 秒后我们将退出程序
time.sleep(2)
# 停用 pygame 库
pygame.quit()
# 退出程序
quit()