From 1aeeb90da2a1c9a93c5aeaf73097259481801420 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Mon, 2 Jan 2023 10:41:46 -0600 Subject: [PATCH] random shaking --- creeper.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/creeper.py b/creeper.py index c38e6c2..238f61f 100755 --- a/creeper.py +++ b/creeper.py @@ -48,6 +48,7 @@ class TreeSprite: def shake(self): if self.shaking == 0: self.shaking = 10 + self.shaking_magnitude = random.randint(0, 10) self.leafs.extend( [ Leaf( @@ -59,7 +60,7 @@ class TreeSprite: ), lifespan=1, ) - for i in range(2) + for i in range(int(self.shaking_magnitude / 2)) ] ) @@ -68,7 +69,7 @@ class TreeSprite: if self.shaking == 0: return 0 self.shaking -= 1 - return random.randint(-15, 15) + return random.randint(-self.shaking_magnitude, self.shaking_magnitude) @property def rect(self):