In later steps, we will be assuming the use of a monitor to display the graphical user interface as part of this tutorial to verify our code.
If you are experiencing issues with installing on the command line, you can check out pygame’s ( Installation). You can exit the Python interactive console with the quit() command. If you receive no errors upon hitting the ENTER key following the command, you will know that pygame was successfully installed. Then within the console you can import the module: First, type the python command to start the console: If you would rather not open up the sample, or if you do not have AV as part of your setup, you can also enter into the Python interactive console to ensure that you can import the pygame module. If you have installed pygame into a system with video and audio available, you can verify your installation by running the following command, which will run a mock game showcasing what pygame can do with graphics and sound: Once you run this command, you should see output that looks similar to the following:
With this activated, you can install pygame with pip: Let’s begin by activating our Python 3 programming environment: With a programming environment set up and a familiarity with Python programming you are ready to begin working with pygame. You should also be familiar with the following Python programming concepts: To be able to use this tutorial, make sure you have Python 3 and a programming environment already installed on your local computer or server. This tutorial will first go through installing pygame into your Python programming environment, and then walk you through creating a template to develop games with pygame and Python 3.
Built on top of the highly portable SDL (Simple DirectMedia Layer) development library, pygame can run across many platforms and operating systems.īy using the pygame module, you can control the logic and graphics of your games without worrying about the backend complexities required for working with video and audio. The pygame library is an open-source module for the Python programming language specifically intended to help you make games and other multimedia applications.