[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Rect's real width and height



> I think, there is something wrong...
> (The same is for all other rect's methods returning coordinates)
> 
> Hey, this rect is actually 11 points width and 11 points height.
> Am I  missing something?

heya ludek, no a keen observation. here's what's going on.
in pygame. all the rect's "right" and "bottom" edges are
non-inclusive. this may seem strange at first, but you'l
find it's the way graphic libraries are commonly done.

as a "feature", what this does is allow you to align 
objects together, but not have to worry about "overlap".
imagine you have code like
>>> object1.rect.left = object2.rect.right

with the rects setup the way they are, these two objects
will line up right next to each other. not overlapped by
1 pixel.

as with any solution, this one isn't the best in ALL
situations, but for moving graphics around the screen,
it makes things much more straightforward. the good
news is that all pygame functions dealing with Rects
are setup to work like this. so collision detection,
blitting, filling, clipping, etc all work correctly
with these rectangles. it was one of those 'weird
decision' things back when i was creating everything.
but since then i've never had to think about it when
doing any of the examples or games.



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org