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 ...

Get Python Projects for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.