summaryrefslogtreecommitdiff
path: root/src/sliceitoff/enemies/enemies.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/enemies/enemies.py')
-rw-r--r--src/sliceitoff/enemies/enemies.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/sliceitoff/enemies/enemies.py b/src/sliceitoff/enemies/enemies.py
index e9b4829..66ebcbd 100644
--- a/src/sliceitoff/enemies/enemies.py
+++ b/src/sliceitoff/enemies/enemies.py
@@ -9,11 +9,11 @@ class EnemySprite(pygame.sprite.Sprite):
super().__init__()
self.position = (0, 0)
self.movement = (0, 0)
-
+
def set_position(self, position: tuple):
self.position = position
self.update()
-
+
def set_movement(self, movement: tuple):
self.movement = movement
@@ -25,7 +25,7 @@ class EnemySprite(pygame.sprite.Sprite):
self.rect = pygame.Rect(
Scaling.scale_to_display(self.position),
self.image.get_size())
-
+
def force_right(self):
self.movement = (abs(self.movement[0]), self.movement[1])
@@ -45,7 +45,6 @@ class EnemyBall(EnemySprite):
colored = letter.fill( "black", special_flags = pygame.BLEND_RGBA_MULT)
self.image = pygame.transform.scale_by(letter, 1_000 * Scaling.factor)
self.update()
-
class Enemies(pygame.sprite.Group):
def __init__(self, field = None, count = 0):
@@ -58,8 +57,8 @@ class Enemies(pygame.sprite.Group):
self.field = field
def update(self, field_rects = [], **kwargs):
- super().update(**kwargs)
""" Do actions on enemies that are only partly on the fields """
+ super().update(**kwargs)
for enemy in self.sprites():
for field_rect in field_rects:
# if enemy is completely inside any field do next enemy
@@ -76,7 +75,7 @@ class Enemies(pygame.sprite.Group):
enemy.force_right()
if enemy.rect.y < field.y:
enemy.force_down()
- if ( enemy.rect.x + enemy.rect.w >= field.x + field.w ):
+ if enemy.rect.x + enemy.rect.w >= field.x + field.w:
enemy.force_left()
- if ( enemy.rect.y + enemy.rect.h >= field.y + field.h ):
+ if enemy.rect.y + enemy.rect.h >= field.y + field.h:
enemy.force_up()