Chapter 12

Getting Started with Pygame

Pygame adds a selection of game-ready modules to Python and makes it easy to create games without having to reinvent code that has already been written. Pygame is as easy to use as Python, but includes some unexpectedly powerful features.

Introducing Pygame

Create a Window

Close a Window

Load a Background Image

Read the Mouse

Respond to Keyboard Events

Scan the Keyboard

Create a Timed Loop

Introducing Pygame

You can use a module called Pygame with Python to develop games. Pygame is a game toolkit with many useful features. Pygame makes it easy to create a window on the screen, draw a background, fill it with action, and respond to mouse and keyboard events.

Understanding Computer Games

Almost all computer ...

Get Teach Yourself VISUALLY Raspberry Pi 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.