Lazo Lab Sign up

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

Lesson 10 of 10

Polish and share

Add a high score saved to a file, a sound when eating, and a nicer colour scheme. Then share it. You built a real game!

Key points

  • pygame.mixer.Sound for sounds
  • Save the high score to a file
  • Ideas: walls, power-ups, two players
from pathlib import Path
best_file = Path("highscore.txt")
best = int(best_file.read_text()) if best_file.exists() else 0
if score > best:
    best_file.write_text(str(score))

Your turn

Add a saved high score, then challenge a friend to beat it.

Watch a video on thisOpens YouTube search results for “Polish and share” in a new tab

Quiz · +10 XP

Which Pygame module plays sounds?

Log in to save progress and earn XP.