GUIs & Games

pygame

The training wheels an entire generation of indie game developers learned to ride on.

Install it: pip install pygame

What does it do?

Pygame hands you the basic building blocks of a video game, drawing shapes and sprites on screen, playing sound effects, detecting keyboard and mouse input, checking whether two objects have collided, so you can focus on game logic instead of low-level graphics programming. It won’t power the next AAA blockbuster, but it’s well suited to 2D games: arcade-style shooters, puzzle games, simple platformers. It wraps a lower-level multimedia library called SDL, handling fiddly technical details so your code can just say draw this image here or play this sound now. It has been the default starting point for countless people’s very first game project.

See it in action

This opens a blank game window that stays open and keeps redrawing itself until the person playing closes it.

import pygame

pygame.init()
screen = pygame.display.set_mode((640, 480))
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    screen.fill((30, 30, 30))
    pygame.display.flip()
pygame.quit()

Why would a non-developer care?

It matters because making even a simple game teaches real programming concepts, loops, coordinates, event handling, in a way that feels like play rather than homework, which is why it’s remained a classroom and bootcamp favorite for years.

Real-world examples

Countless indie developers got their start prototyping in Pygame before moving to bigger engines like Unity or Godot for commercial releases. It regularly powers game jams, including its own dedicated annual community jam, where developers build a complete game in a week or two. Schools and coding camps frequently use it to teach programming fundamentals because a moving sprite on screen motivates far better than text printed to a console.

Who uses it

Beginner programmers learning to code, hobbyist game developers, and educators teaching programming through game projects.

How it compares to alternatives

Pygame is simpler and more beginner-friendly than full game engines like Unity or Godot, but it lacks their built-in physics engines, visual editors, and 3D support, and for more modern, hardware-accelerated 2D development, some developers now prefer Arcade, which was built partly as a fresher alternative.

Fun fact

Pygame was first released in 2000 and is still actively used today, old enough to have taught coding to multiple generations of now-professional developers.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries