O'Reilly logo

Invent Your Own Computer Games with Python , 4th Edition by Al Sweigart

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

18ANIMATING GRAPHICS

image

Now that you’ve learned some pygame skills, we’ll write a program to animate boxes that bounce around a window. The boxes are different colors and sizes and move only in diagonal directions. To animate the boxes, we’ll move them a few pixels on each iteration through the game loop. This will make it look like the boxes are moving around the screen.

Sample Run of the Animation Program

When you run the Animation program, it will look something like Figure 18-1. The blocks will be bouncing off the edges of the window. ...

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