Hardware Reference
In-Depth Information
the sprites of Pie Man and the ghosts into the screen layer. Although blitting involves transfer-
ring a lot of data from one place to another, it is relatively quick and eicient because it is coded
in a low-level machine code that can be executed quickly. One thing you must ensure, however,
is that the pill layer's background is transparent so that it does not obscure the walls in the
background layer. In Pygame this is done by telling the system that one colour should be
treated as being transparent. his is known as the color key. Figure 6-6 shows the arrangement
of the layers. Notice that the screen layer is wider than the background or the pills layer because
irst of all, you need to have room for the score and lives-left indicator and second, you need the
extra space to cope with the tunnel from one side of the screen to the other.
Figure 6-6:
Screen drawing
planes.
Now it is time for your irst chunk of code - basically the functions that set up the back-
ground layer. As mentioned before, all these listings need to go into one ile, so set up a ile
called pieMan.py in the same folder as the sound and graphics resources and type in the
code in Listing 6-1.
Listing 6-1 Setting Up the Background
def setupBackground():
walkIncrement = 8
Search WWH ::




Custom Search