+ def get_grid_surface(self, game_surface):
+ grid_size = 4
+ if self.grid_surface is None:
+ rect = game_surface.get_rect()
+ size = (rect.width, rect.height)
+ self.grid_surface = pygame.surface.Surface(
+ size, flags=pgl.SRCALPHA)
+ for i in range(0, rect.width, grid_size):
+ for j in range(0, rect.height, grid_size):
+ if (i + j) % (grid_size * 2) == 0:
+ continue
+ pygame.draw.rect(self.grid_surface, PALETTE.GREY,
+ (i, j, grid_size, grid_size))
+ return self.grid_surface
+
+ def grid_out(self, game_surface, rect):
+ orig = game_surface.copy()
+ game_surface.blit(self.get_grid_surface(game_surface), (0, 0))
+ game_surface.blit(orig, rect, rect)
+ pygame.draw.rect(game_surface, PALETTE.GREEN, rect, 8)
+