Animations on updating

20 Sep

In this program we have several different blocks bouncing off of the edges of the window.The blocks are different colors and sizes and move only in diagonal directions.This makes it easier to distinguish the data types and the modules. This is because modifying the Surface object in the computer’s memory is much faster than modifying the image on the screen.It is much more efficient to draw onto the screen once after all of the drawing functions have drawn to the surface. The third parameter is a tuple of four integers for the left, top, width, and height of the rectangle.This is why you want the drawn rectangle’s left and top to be the left and top of object with this change.The first index in the Pixel Array object is for the X-coordinate. Pixel Array objects make it easy to set individual pixels on a Pixel Array object to a specific color. This is because drawing to the screen is slow compared to drawing on the Surface objects in the computer’s memory.Figure 17-3 shows the same sentence printed in different fonts.

Moving and Bouncing the Blocks Each block will move in one of four diagonal directions.

To check that Pygame installed correctly, type the following into the interactive shell: has information on how to use Pygame, as well as several other game programs made with Pygame. What is nice about using a window instead of a console is that the text can appear anywhere in the window, not just after the previous text you have printed. The window is like a blank painting canvas, and you can draw whatever you like on it.

Importing the Pygame Module Let’s go over each of these lines of code and find out what they do.

) A pixel is the tiniest dot on your computer screen.

A single pixel on your screen can light up into any color.