summaryrefslogtreecommitdiff
path: root/src/sliceitoff/text/explode.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-04-07 23:25:09 +0300
committerViljami Ilola <+@hix.fi>2024-04-07 23:25:09 +0300
commit6ba20c61a04c688120161f6c5fbb56102f8082ef (patch)
tree33291a2c494b8fe5e126e31b5ce719aa0df0feec /src/sliceitoff/text/explode.py
parentd2e42bfa99d8bb417d8eaf365d290a071ad49b7f (diff)
exploding sprites and groups as their own. more refactoring.
Diffstat (limited to 'src/sliceitoff/text/explode.py')
-rw-r--r--src/sliceitoff/text/explode.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/sliceitoff/text/explode.py b/src/sliceitoff/text/explode.py
new file mode 100644
index 0000000..4925398
--- /dev/null
+++ b/src/sliceitoff/text/explode.py
@@ -0,0 +1,27 @@
+""" text.explode - Exploding effect movements and updates for the sprite """
+from random import randrange
+
+import pygame
+
+from display import Scaling
+
+class ExplodingSprite(pygame.sprite.Sprite):
+ """ Just adds exloding movement to the sprite """
+ def __init__(self):
+ super().__init__()
+ self.rect = None
+ self.direction = (
+ Scaling.factor * (1_000 - randrange(2_000)),
+ Scaling.factor * (1_000 - randrange(2_000)))
+
+ def update(self, dt = 0, explode = 0):
+ """ Exploding movement """
+ if explode and dt:
+ self.rect = pygame.Rect(
+ self.rect.x + self.direction[0] * dt,
+ self.rect.y + self.direction[1] * dt,
+ self.rect.w,
+ self.rect.h)
+ self.direction = (
+ self.direction[0] * 0.95,
+ self.direction[1] * 0.95 + 0.3)