Game Development Reference
In-Depth Information
Anti-aliasing can make your text and lines
look blurry but smoother. It takes a little more
computation time to do anti-aliasing, so although
the graphics may look better, your program may
run slower (but only just a little).
Figure 17-4: An aliased line and an anti-aliased line.
Attributes
24. textRect.centerx = windowSurface.get_rect().centerx
25. textRect.centery = windowSurface.get_rect().centery
The pygame.Rect data type (which we will just call Rect for short) makes working
with rectangle-shaped things easy. To create a new Rect object call the function
pygame.Rect() . The parameters are integers for the XY coordinates of the top left
corner, followed by the width and height. These integers are in number of pixels.
The function name with the parameters looks like this: pygame.Rect(left, top,
width, height)
Just like methods are functions that are associated with an object, attributes are
variables that are associated with an object. The Rect data type (that is, the data type of all
Rect objects) has many attributes that describe the rectangle they represent. Here is a list
of attributes of a Rect object named myRect :
pygame.Rect
Attribute
Description
The int value of the X-coordinate of the left side of the
rectangle.
myRect.left
The int value of the X-coordinate of the right side of the
rectangle.
myRect.right
The int value of the Y-coordinate of the top side of the
rectangle.
myRect.top
The int value of the Y-coordinate of the bottom side of the
rectangle.
myRect.bottom
The int value of the X-coordinate of the center of the
rectangle.
The int value of the Y-coordinate of the center of the
myRect.centerx
Search WWH ::




Custom Search