diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-30 16:08:03 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-30 16:08:03 +0200 |
commit | 1def24341ce4f3ab1c1de4a9dde27bf0b5fab179 (patch) | |
tree | e846c7ea2f4306146f33381c289350c2edf6f093 /src/sliceitoff/enemies/ball.py | |
parent | 5874005e58d0f26b4393845b3b18160658ece160 (diff) |
bounching balls and more refactoring
Diffstat (limited to 'src/sliceitoff/enemies/ball.py')
-rw-r--r-- | src/sliceitoff/enemies/ball.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/sliceitoff/enemies/ball.py b/src/sliceitoff/enemies/ball.py new file mode 100644 index 0000000..b8c8467 --- /dev/null +++ b/src/sliceitoff/enemies/ball.py @@ -0,0 +1,27 @@ +""" enemies.ball - Enemy type that goes straight line hitting walls """ +from random import randrange, choice + +from text import get_letter_surface +from .enemy import Enemy + +BALL_SPAWN_AREA = (0, 0, 300_000, 200_000) +BALL_MOVEMENT = (100, 100) +BALL_SYMBOLS = (0x1,0x2) +BALL_SIZE = 8_000 + +class EnemyBall(Enemy): + """ Basic type of enemy. """ + def __init__(self): + super().__init__() + self.position = ( + randrange(BALL_SPAWN_AREA[0], BALL_SPAWN_AREA[2]), + randrange(BALL_SPAWN_AREA[1], BALL_SPAWN_AREA[3])) + self.movement = ( + randrange(0, BALL_MOVEMENT[0]*2) - BALL_MOVEMENT[0], + randrange(0, BALL_MOVEMENT[1]*2) - BALL_MOVEMENT[1]) + font_key = ('8x8', BALL_SIZE, 0) + surface = get_letter_surface(font_key, choice(BALL_SYMBOLS)) + self.image = surface.subsurface( + (0, 0, surface.get_rect().w, surface.get_rect().w)) + self.update() + self.rect = None |