summaryrefslogtreecommitdiff
path: root/src/sliceitoff/enemies
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-29 18:39:41 +0200
committerViljami Ilola <+@hix.fi>2024-03-29 18:39:41 +0200
commita9631796cf6d03946c6d1a72fba3cff554bd0f5c (patch)
tree27713cd7325aa55428f066b7fccdde0a74b862f9 /src/sliceitoff/enemies
parent7765d20550a8d5680b624f6063b4d2b23a094fed (diff)
docstrings
Diffstat (limited to 'src/sliceitoff/enemies')
-rw-r--r--src/sliceitoff/enemies/__init__.py1
-rw-r--r--src/sliceitoff/enemies/enemies.py13
2 files changed, 7 insertions, 7 deletions
diff --git a/src/sliceitoff/enemies/__init__.py b/src/sliceitoff/enemies/__init__.py
index 2d00927..0f06761 100644
--- a/src/sliceitoff/enemies/__init__.py
+++ b/src/sliceitoff/enemies/__init__.py
@@ -1 +1,2 @@
+""" enemies - enemies as sprites and groups """
from .enemies import Enemies
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()