Reputation: 25
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()))
WIDTH and HEIGHT = screens width and height
x and o scores are defined
pygame and font are initialized from the start
Called pygame.display.flip()
after the function
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
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