def run(self):
while not self.done:
# if user clicks close, then exit
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
grid = self.grid
self.screen.fill(EMPTY_COLOR)
for row in range(len(grid)):
for col in range(len(grid[0])):
color = grid[row][col]
pygame.draw.rect(self.screen, color,
[(MARGIN + WIDTH) * col + MARGIN,
(MARGIN + HEIGHT) * row + MARGIN,
WIDTH, HEIGHT])
# Limit to 30 frames per second
self.clock.tick(30)
pygame.display.flip()
pygame.quit()
评论列表
文章目录