diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-23 21:02:56 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-23 21:02:56 +0200 |
commit | 947df85053af2704ce1a17daf1fab13e273f0cc5 (patch) | |
tree | ece2e9e807e74988b36ec5fac0de7dcc9b4efca2 /src/sliceitoff/enemies | |
parent | 87cd7293498d6b30389e056a59b2e69eb7b3a418 (diff) |
remove cross dependencies. moving logic towards game/...
Diffstat (limited to 'src/sliceitoff/enemies')
-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) |