diff --git a/falling_sand.py b/falling_sand.py index 647efad..d883e8d 100644 --- a/falling_sand.py +++ b/falling_sand.py @@ -115,7 +115,7 @@ class FallingSand: self.mouse = pygame.mouse self.mouse_pressed = self.mouse.get_pressed() self.mouse_pos = self.mouse.get_pos() - self.sand_surface = pygame.Surface(self.screen.get_size()) + self.sand_surface = pygame.Surface(self.settings.window_size) self.sand_surface.fill(self.gray) self.matrix = pygame.PixelArray(self.sand_surface) @@ -187,7 +187,15 @@ class FallingSand: print("Bye!") def window_update(self, size): + w, h = size + self.settings.window_size = size + self.matrix.close() + old_sand_surface = self.sand_surface + self.sand_surface = pygame.Surface(size) + self.sand_surface.fill(self.gray) + self.sand_surface.blit(old_sand_surface, (0, 0)) + self.matrix = pygame.PixelArray(self.sand_surface) def spawn_sand(self, position): for ax in range(-8, 9):