Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pygame Rect, what are the arguments?

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.

like image 797
Andrew Lalis Avatar asked Jan 04 '15 21:01

Andrew Lalis


1 Answers

Both of them work:

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))
like image 112
tckmn Avatar answered Oct 13 '22 17:10

tckmn