diff --git a/falling_sand.py b/falling_sand.py index e89c509..647efad 100644 --- a/falling_sand.py +++ b/falling_sand.py @@ -175,6 +175,10 @@ class FallingSand: elif event.type == pygame.VIDEORESIZE: self.window_update(event.size) + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_r: + self.reset_sand_particles() + def exit(self): self.running = False @@ -228,6 +232,11 @@ class FallingSand: return tuple(color) + def reset_sand_particles(self): + self.falling_sand_particles.clear() + self.sand_surface.fill(self.gray) + self.rainbow_data = [[255, 40, 40], 0] + if __name__ == "__main__": sand = FallingSand()