random shaking

This commit is contained in:
Waylon Walker 2023-01-02 10:41:46 -06:00
parent 22e85de73d
commit 1aeeb90da2
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4

View file

@ -48,6 +48,7 @@ class TreeSprite:
def shake(self): def shake(self):
if self.shaking == 0: if self.shaking == 0:
self.shaking = 10 self.shaking = 10
self.shaking_magnitude = random.randint(0, 10)
self.leafs.extend( self.leafs.extend(
[ [
Leaf( Leaf(
@ -59,7 +60,7 @@ class TreeSprite:
), ),
lifespan=1, 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: if self.shaking == 0:
return 0 return 0
self.shaking -= 1 self.shaking -= 1
return random.randint(-15, 15) return random.randint(-self.shaking_magnitude, self.shaking_magnitude)
@property @property
def rect(self): def rect(self):