0

I enter this code but all that appears is a black rectangle. What do I do to make it output the player_score variable in text?.

font = pygame.font.Font("LEMONMILK-Regular.otf", 30)

player_score = 0
player_score_text = font.render(str(player_score), True, pygame.Color("black"), pygame.Color("white"))

player_score_rect = player_score_text.get_rect()
player_score_rect.center = (200,200)

pygame.draw.rect(screen, black, player_score_rect)

I'm trying to make player_score appear on the screen in the LEMONMILK-Regular.otf font as text.

  • `font.render` just creates a _Surface_. You have to `blit` that _Surface_ on the `screen`. e.g.: `screen.blit(player_score_text, player_score_rect)` (instead of `pygame.draw.rect(screen, black, player_score_rect)`). – Rabbid76 Dec 20 '22 at 16:36

0 Answers0