[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] board game
On Fri, 16 Nov 2007 08:49:21 +1030, "David Gowers" <00ai99@xxxxxxxxx>
wrote:
> for x in range (0, numsquares_x):
> for y in range (0, numsquares_y):
> thissq = pygame.rect (x * square_width, y * square_height,(x+1) *
> square_width, (y+1) * square_height)
> squares.append (thissq)
I think he means for that one line:
thissq = pygame.rect.Rect( x*square_width, y*square_height, square_width,
square_height )
since the format is:
pygame.Rect(left, top, width, height)
But yeah, Rect objects don't need to be "associated with" an image/surface.
They're basically just 4-item tuples, and you can even use such tuples
interchangeably for some functions. You can use rects for other things too,
like testing whether a point is within some area.