Lazo Lab Sign up

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

Lesson 1 of 10

Setting up Pygame

Pygame draws graphics, plays sounds and reads the keyboard. Install it in a virtual environment and open a window.

Key points

  • pip install pygame
  • pygame.init() first
  • set_mode((w, h)) makes the window
import pygame
pygame.init()
screen = pygame.display.set_mode((600, 600))
pygame.display.set_caption("Snake")

Your turn

Make a snake-game folder, install pygame and open a 600 by 600 window.

Watch a video on thisOpens YouTube search results for “Setting up Pygame” in a new tab

Quiz · +10 XP

What must you call before using most of Pygame?

Log in to save progress and earn XP.