Kory
Kory

Reputation: 25

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()))

I have everything else in my code displaying BUT this. Can anyone help me out and tell me what I'm doing wrong on trying to display the scores?

Upvotes: 1

Views: 106

Answers (1)

Rabbid76
Rabbid76

Reputation: 210876

The score is at the bottom outside the window. Change the calculation of the y-coordinate. The vertical position is HEIGHT - SCORE.get_height() instead of 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()))

Upvotes: 1

Related Questions