From 6da49ee7a6631d1b5092b5aa1fbf5a6f9fb8477e Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Mon, 26 Feb 2024 13:12:20 +0100 Subject: [PATCH] Added reset shortcut. --- falling_sand.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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()