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

Re: [pygame] strange rect behavior...



> Still, I find this behavior strange.The doc is not very clear. 

The online doc has just been updated:
  http://www.pygame.org/docs/ref/rect.html

> Beside this seems to me non-standard. When you're setting the bottom
> right of a rect, you could do it to resize or to move. Both motives
> are equally valid and correct . Why excluding resize ?

You have to choose one when assigning. If you assign to rect.right, the
library can't just guess whether you want to resize or not.

Visual Basic resolves this question more directly: it doesn't allow you
to assign to "right" or "bottom". Pygame lets you assign to them, but it
means you have to know what you're doing.

> Beside, the attributes are in the "same bag", why a user must remember
> which attributes is resize, which is move ?

I found it a little unintuitive at first too. But if you consider the
kind of 2D games that would logically use Rect, I think you'll see that
they do a lot more moving of images than resizing. Pygame makes the most
common case the easiest.

So the rule is: if you're not sure, the Rect is moved rather than
resized. The only attributes that resize are "width", "height" and
"size", and I can't imagine them doing anything else.

-- 
  In the early 1980s, teenagers began "getting high" from aerosols,
  despite clear warnings of death. Then liability lawyer Victor E.
  Schwartz suggested adding a (false) warning of facial
  disfigurement. According to Schwartz, "We haven't had a liability
  claim since."