Well I know nothing of Python, but as far as a 'general' (java/javascript/actionscript) approach, I'd probably do something like the following pseudocode. I'm assuming draw.rect's 0,0 means starting at x,y - so here goes:
for h in range (0, num_column) :
for w in range (0, num_row) :
color = color1
if((h + w) % 2 == 1) color = color2
pygame.draw.rect(screen, color, (w * rect_Width, h * rect_Height, rect_Width, rect_Height))
else:
else:
As I said before, this is pseudocode and I know nothing about Python *I had to look up the for code, and there's a big chance I'm not using it 100% correct* - but it should give you some pointers. Here's a generic breakdown of what it does:
- The double for-loop makes sure you call the code for each rectangle
- the if statement leaves the color either at color1 or sets it to color2, by checking if h + w is uneven (1) - this is some pretty heavy pseudocode, beware!
- you then use the draw.rect with the width and height params you created in the for loops.