summaryrefslogtreecommitdiff
path: root/src/sliceitoff/text/explode.py
diff options
context:
space:
mode:
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)