Lazo Lab Sign up

App 6: Make a Game, Snake in Pygame / Build Snake

Lesson 8 of 10

Score and text

Show the score with a font. Render text to an image, then blit it onto the screen.

Key points

  • pygame.font.SysFont(None, 32)
  • font.render(text, True, color)
  • screen.blit(image, (x, y))
font = pygame.font.SysFont(None, 32)
score = len(snake) - 3
img = font.render(f"Score: {score}", True, (245, 217, 10))
screen.blit(img, (10, 10))

Your turn

Show the score in the top corner.

Watch a video on thisOpens YouTube search results for “Score and text” in a new tab

Quiz · +10 XP

What does screen.blit do?

Log in to save progress and earn XP.