[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] strange rect behavior...



Well the problem here is not that your rectangle has not changed, its that your rect has the following attributes, (x, y, width, height)  so now if you change the bottom of a rectangle that has a 0 width, and a 0 height, all you're changing is the y value, not the W and H values. So if you want to change the height, then change the location, first setup the height, so rect.height = 10, then change the topleft, or bottomright, or whatever (and remember your right and bottom values change proportional to your width and height!)

On 10/9/05, andrew baker <failrate@xxxxxxxxx > wrote:
I believe Rects have their handle on the top-left.  That's fairly common, so, yes...  bottom should be top + height.  Remember, you'll generally increment to go down the y onscreen and decrement to go up.  This seems backwards compared to Cartesian graphs, but you should remember that it has more to do with the top-left of your screen being the origin for all mapping.  The top-left is 0,0.


On 10/9/05, Lionel barret De Nazaris < lionel.bdn@xxxxxxx > wrote:
hello all,  (possibly newbie question)

If I write :
rect = pygame.Rect ([0,0,0,0])
rect.bottom = 100
print rect.height

I get :
0

I thought that : Bottom = Top + Height..
Is This correct ? and Why ?
Looks very strange from the outside.

Thanks,
Lionel.





--
Andrew Ulysses Baker
"failrate"