O'Reilly logo

Python Projects for Kids by Jessica Ingrassellino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required