summaryrefslogtreecommitdiff
path: root/src/sliceitoff/enemies/bouncher.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/enemies/bouncher.py')
-rw-r--r--src/sliceitoff/enemies/bouncher.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/sliceitoff/enemies/bouncher.py b/src/sliceitoff/enemies/bouncher.py
new file mode 100644
index 0000000..692492b
--- /dev/null
+++ b/src/sliceitoff/enemies/bouncher.py
@@ -0,0 +1,36 @@
+""" enemies.bouncher - Enemy type that bouches around """
+from random import randrange, choice
+
+from text import get_letter_surface
+from .enemy import Enemy
+
+BOUNCHER_SPAWN_AREA = (0, 0, 300_000, 80_000)
+BOUNCHER_MOVEMENT = (200, 20)
+BOUNCHER_SIZE = 12_000
+BOUNCHER_SYMBOLS = (0x1,0x2)
+GRAVITY = 4
+
+class EnemyBouncher(Enemy):
+ """ Type of enemy that is affected by gravity """
+ def __init__(self):
+ super().__init__()
+ self.position = (
+ randrange(BOUNCHER_SPAWN_AREA[0], BOUNCHER_SPAWN_AREA[2]),
+ randrange(BOUNCHER_SPAWN_AREA[1], BOUNCHER_SPAWN_AREA[3]))
+ self.movement = (
+ randrange(0, BOUNCHER_MOVEMENT[0]*2) - BOUNCHER_MOVEMENT[0],
+ randrange(0, BOUNCHER_MOVEMENT[1]*2) - BOUNCHER_MOVEMENT[1])
+ font_key = ('8x8', BOUNCHER_SIZE, 0)
+ surface = get_letter_surface(font_key, choice(BOUNCHER_SYMBOLS))
+ self.image = surface.subsurface(
+ (0, 0, surface.get_rect().w, surface.get_rect().w))
+ self.rect = None
+ self.update()
+
+ def update(self, dt = 0, wall_hit = None, **kwargs):
+ """ wall hit from super(). added gravity """
+ super().update(dt = dt, wall_hit = wall_hit, **kwargs)
+ if dt:
+ self.movement = (
+ self.movement[0],
+ (self.movement[1] + GRAVITY)*0.999)