From 975e5dca49fb09fe2f762462f1c337c0d63735bf Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Wed, 20 Mar 2024 17:46:10 +0200 Subject: exploding text --- src/sliceitoff/text/text.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/sliceitoff/text') diff --git a/src/sliceitoff/text/text.py b/src/sliceitoff/text/text.py index f01e517..e86bede 100644 --- a/src/sliceitoff/text/text.py +++ b/src/sliceitoff/text/text.py @@ -12,8 +12,20 @@ class LetterSprite(pygame.sprite.Sprite): self.image = image self.rect = self.image.get_rect().move(pos) self.direction = ( - Scaling.factor * 40 * 1_000 + randrange(4_000), - Scaling.factor * 40 * 1_000 + randrange(4_000)) + Scaling.factor * (2_000 - randrange(4_000)), + Scaling.factor * (2_000 - randrange(4_000))) + + def update(self, explode=0): + if explode: + self.rect = pygame.Rect( + self.rect.x + self.direction[0] * explode, + self.rect.y + self.direction[1] * explode, + self.rect.w, + self.rect.h) + self.direction = ( + self.direction[0] * 1.15, + self.direction[1] * 1.15) + class TextPage(pygame.sprite.Group): def __init__( -- cgit v1.2.3