Background and Setup
What is PyGame and where did it come from? In this lesson, you’ll explore some of the background of
pygame and how to set it up on your system.
pygame is a Python wrapper for the SDL library, which stands for Simple DirectMedia Layer. SDL provides cross-platform access to your system’s underlying multimedia hardware components, such as sound, video, mouse, keyboard, and joystick.
pygame started life as a replacement for the stalled PySDL project. The cross-platform nature of both SDL and
pygame means you can write games and rich multimedia Python programs for every platform that supports them!
For this tutorial, the demonstrations shown will be done on a Macintosh computer, and the Python environment is setup with a virtual environment. To create a virtual environment on macOS or Windows and activate it, you would use these commands from your terminal:
$ mkdir PyGame $ cd PyGame $ python3 -m venv game_env $ # macOS virtual environment activation $ source game_env/bin/activate $ # Windows virtual environment activation $ game_env/Scripts/activate
pygame into your virtual environment or your platform, use the
(game_env) $ python3 -m pip install pygame
You can verify the install by loading one of the examples that comes with the library:
(game_env) $ python3 -m pygame.examples.aliens
If a game window appears, then
pygame is installed properly! If you run into problems, then the GettingStarted guide outlines some known issues and caveats for all platforms.
Become a Member to join the conversation.