[Tutor] using rect.inflate()

Christopher Spears cspears2002 at yahoo.com
Thu Nov 6 02:05:08 CET 2008


I'm modifying a game for an assignment in "Game Programming" by Andy Harris.  I'm not reading this book as part of a class.

Basically, I turned one of the example games into an Asteroid rip off.  However, I didn't like the collisions between the spaceship and the asteroids, so I decided to shrink the ship's bounding box using Rect.inflate().

I inserted this code snippet into the Spaceship class:

self.rect = self.image.get_rect()
print self.rect
self.rect = self.rect.inflate(-50, -50)
print self.rect

The following was printed to my console:
<rect<0, 0, 70, 53>>
<rect<25, 25, 20, 37>>

I'm assuming that the first two numbers are coordinates for the upper left corner of the rectangle.  The third and fourth numbers are the width and height of the rectangle from the upper left corner.  Am I off base here?
If that is the case, why does rect.inflate() move the upper left corner?


      


More information about the Tutor mailing list