Chapter 17. Sprites and Collision Detection
In this chapter, we’ll continue using Pygame to do animation. We’ll look at things called sprites, which help us keep track of lots of images moving on the screen. We’ll also see how to detect when two images overlap or hit each other, like when a ball hits a paddle or a spaceship hits an asteroid.
Sprites
In the last chapter, you saw that simple animation isn’t quite so simple after all. If you have a lot of images and are moving them around, it can be a lot of work keeping track of what’s “under” each image so you can repaint when you move the image. In our first example with the beach ball, the background was just white, so it was easier. But you can imagine that, with graphics in the background, ...
Get Hello World! Third Edition 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.