192 Chapter 8
Let’s figure out what that value might be. We know our
screen is 600 pixels wide because we created our screen with
pygame.display.set_mode([600,600]). We could use 600 as our bound-
ary, but the smiley face would still go off the edge of the screen
because the coordinate pair (picx,picy) is the location of the top-left
pixel of our smiley face image.
To find our logical boundary—that is, the virtual line that picx
has to reach for our smiley face to look like it has hit the right edge
of the screen window—we need to know how wide our picture is.
Because we know picx is the top-left corner of the image and it con-
tinues to the right, we can just add the width of our picture to picx,
and when that sum equals 600, we’ll know that the right edge of
the image is touching the right edge of the window.
One way to find the width of our image is by looking at the
properties of the file. In Windows, right-click the CrazySmile.bmp
file, select the Properties menu item, and then click the Details
tab. On a Mac, click the CrazySmile.bmp file to select it, press z-I
to get the file info window, and then click More Info. You’ll see the
width and height of the picture, as shown in Figure 8-7.
Figure 8-7: To determine our virtual boundaries so our smiley face
can bounce off them, we need to know the width of our image file.