

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Build an Asteroids Game
incomplete
2: Installation
incomplete
3: Pygame
incomplete
4: Reading the Docs
incomplete
This lesson's interactive features are locked, please to keep using them
We're going to be using Pygame and a virtual environment to develop our game.
Pygame is a module for developing games using Python. It provides simple functions and methods for us to draw images within a GUI window and handle user input.
Unfortunately, Pygame does not yet support Python 3.14. Until it's updated, we recommend using Python 3.13. uv init --no-package --python 3.13 can manage that project version for you.
Virtual environments are Python's way to keep dependencies (e.g., the pygame module) separate from other projects on our machine. For example, we need pygame version 2 for this project, but another project on your computer might require version 1.
As a best practice, each Python project on your machine should have its own virtual environment to keep things isolated.
uv init --no-package --python 3.13 your-project-name
cd your-project-name
--python 3.13 pins your project's Python version to 3.13
uv venv
source .venv/bin/activate
You should see (your-project-name) at the beginning of your terminal prompt – for example, mine is:
(Asteroids) wagslane@MacBook-Pro-2 Asteroids %
Make sure your virtual environment is activated when running the game or using the bootdev CLI.
uv add pygame==2.6.1
This tells Python that this project requires pygame with an exact version of 2.6.1.
uv run -m pygame
This will result in an error (the test expects an exit code of 1), but the output will show that pygame is installed.
Submit the CLI tests. There's no penalty on failure for this lesson.
If you're on WSL and pygame can't open a window, you may need to install VcXsrv. (What is VcXsrv?) Install the latest release. If you need help at any point, ask in the community Discord.