diff options
Diffstat (limited to 'src/sliceitoff/enemies/enemies.py')
-rw-r--r-- | src/sliceitoff/enemies/enemies.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/sliceitoff/enemies/enemies.py b/src/sliceitoff/enemies/enemies.py index aaa41be..3f206c7 100644 --- a/src/sliceitoff/enemies/enemies.py +++ b/src/sliceitoff/enemies/enemies.py @@ -65,15 +65,16 @@ class Enemies(pygame.sprite.Group): enemy.force_left() if ( enemy.rect.y + enemy.rect.h >= field.rect.y + field.rect.h ): enemy.force_up() - - def update(self, dt = 0): - """ Update sprites basis of dt. dt = milliseconds from last update """ - super().update(dt = dt) + + def hit_walls(self, field_sprites): + """ Do actions on enemies that are only partly on the fields """ for enemy in self.sprites(): - for field in self.field.sprites(): + for field in field_sprites: + # if enemy is completely inside any field do next enemy if field.rect.contains(enemy): break else: - for field in self.field.sprites(): + # now find field that enemy is partly on + for field in field_sprites: if field.rect.colliderect(enemy): self.wall_hit(field, enemy) |