Pygame Rect, what are the arguments?
14,748
class pygame.Rect
pygame object for storing rectangular coordinates
Rect(left, top, width, height) -> Rect
Rect((left, top), (width, height)) -> Rect
Rect(object) -> Rect
So, if you have coordinates (x1, y1)
and (x2, y2)
, both of the following would work:
pygame.Rect(x1, y1, x2-x1, y2-y1)
pygame.Rect((x1, y1), (x2-x1, y2-y1))
Comments
-
Andrew Lalis almost 2 years
I know this may sound stupid, but the pygame documentation on their website says that it is:
x = pygame.Rect(left,top,width,height)
However, in my program, I cannot figure out if that is true, or if the arguments are actually two sets of coordinates. I'm not nearly experienced to find out by looking through the pygame source code.
-
Andrew Lalis over 9 yearsbut could I also put Rect(x1,y1,x2,y2)? as in two sets of coordinates
-
tckmn over 9 years@AndrewLalis No, it would be
Rect(x1, y1, x2-x1, y2-y1)
. The second pair of arguments is the width and the height.