summaryrefslogtreecommitdiff
path: root/src/sliceitoff/text/text.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/text.py
parentd2e42bfa99d8bb417d8eaf365d290a071ad49b7f (diff)
exploding sprites and groups as their own. more refactoring.
Diffstat (limited to 'src/sliceitoff/text/text.py')
-rw-r--r--src/sliceitoff/text/text.py20
1 files changed, 2 insertions, 18 deletions
diff --git a/src/sliceitoff/text/text.py b/src/sliceitoff/text/text.py
index c429110..69fee77 100644
--- a/src/sliceitoff/text/text.py
+++ b/src/sliceitoff/text/text.py
@@ -1,10 +1,9 @@
""" text.text - letters, texts and scaling and coloring of fonts """
-from random import randrange
-
import pygame
from display import Scaling, CGA_COLORS
from .fonts import Fonts
+from .explode import ExplodingSprite
scaled_fonts = {}
@@ -31,28 +30,13 @@ def get_letter_surface(font_key, ch):
return scaled_fonts[font_key][ch]
-class LetterSprite(pygame.sprite.Sprite):
+class LetterSprite(ExplodingSprite):
""" Make sprite out of letter surface at given position """
def __init__(self, font_key, ch, pos):
super().__init__()
self.dead = True
self.image = get_letter_surface(font_key, ch)
self.rect = self.image.get_rect().move(pos)
- self.direction = (
- Scaling.factor * (1_000 - randrange(2_000)),
- Scaling.factor * (1_000 - randrange(2_000)))
-
- def update(self, dt = 0, explode = 0):
- """ All the movements for letters """
- 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)
class TextPage(pygame.sprite.Group):
""" Creates sprite group out of given text and parameters