Pygame 文字不显示

Pygame Text Doesn't Display

def score():
    global x_score, o_score
    
    scoreFont = pygame.font.SysFont('Comic Sans', 20, bold=True)
    SCORE = scoreFont.render(f'X   {x_score} : {o_score}   O', True, (0, 0, 0))
    screen.blit(SCORE, ((WIDTH / 2) - (SCORE.get_width() / 2), HEIGHT + SCORE.get_height()))

除了这个,我的代码中还有其他所有内容。任何人都可以帮助我并告诉我我在尝试显示分数时做错了什么吗?

得分在window外垫底。更改 y 坐标的计算。垂直位置是 HEIGHT - SCORE.get_height() 而不是 HEIGHT + SCORE.get_height():

screen.blit(SCORE, ((WIDTH / 2) - (SCORE.get_width() / 2), HEIGHT + SCORE.get_height()))

screen.blit(SCORE, ((WIDTH / 2) - (SCORE.get_width() / 2), HEIGHT - SCORE.get_height()))