pygame
To test the pygame functions, open your text editor, create a file called sample.py
, and save this file in your work folder. Once you have created this file, you are ready to start learning pygame. To use pygame, we will import the pygame module in the first line of our sample.py
file:
import pygame
Initializing pygame
Next, we need to take a look at the methods that we need in order to start our instance of pygame. To start pygame, we need to initialize an instance of all the pygame modules. We do this by calling the init()
function:
pygame.init()
A pygame game loop is the same as the game loops that we used in previous projects. In this chapter, it will be a while
loop that uses while True
in order to indicate that the game loop should repeat itself over and over again until it is stopped:
Setting up the game screen – size
Once we have pygame set up and initialized, we will want to know how to make a basic background screen. First, you will learn how to set the size of our screen. Then...