I'm trying to make a chess game in python and to draw the boards, I'm using nested for loops. the problem I'm encountering is that when it comes to coloring the board, the logic I'm using just colors the rows 1, 5. I don't know if I'm doing the mod stuff right. Thanks
def draw_board(self, screen):
for i in range(0, 8):
i *= screen.get_width() / 8
for j in range(0, 8):
# j - x
# i - y
print(j, i)
j *= screen.get_height() / 8
square = pygame.Surface((screen.get_width() / 9, screen.get_height() / 9))
if j % 2 == 0:
square.fill((238, 238, 210))
else:
square.fill((118, 150, 86))
screen.blit(square, (i, j))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…