diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-23 20:19:38 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-23 20:19:38 +0200 |
commit | 87cd7293498d6b30389e056a59b2e69eb7b3a418 (patch) | |
tree | 392e2e15446a533d0bdc1faddd5a6e2d8fc731ee /src/sliceitoff/player/player.py | |
parent | b03cb075e7a2042764a355a46d649b187f66343b (diff) |
enemies as group
Diffstat (limited to 'src/sliceitoff/player/player.py')
-rw-r--r-- | src/sliceitoff/player/player.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/sliceitoff/player/player.py b/src/sliceitoff/player/player.py index 6e2ab0b..d36691c 100644 --- a/src/sliceitoff/player/player.py +++ b/src/sliceitoff/player/player.py @@ -17,13 +17,13 @@ class PlayerSprite(pygame.sprite.Sprite): class Player(): def __init__(self, field = None, enemies = None): - self.field = field self.enemies = enemies self.position = (200_000, 140_000) self.direction = False self.lazer = False self.sprites = pygame.sprite.Group() self.updated = True + self.field = field def __update_sprites(self): self.sprites.empty() @@ -49,16 +49,13 @@ class Player(): def fire_lazer(self): if DEBUG: print("PLAYER: fire lazer") - # self.lazer = True - # self.updated = True hitbox = self.field.slice(self.position, self.direction, 4_500) hit = False if hitbox is not None: - for enemy in self.enemies.sprites: + for enemy in self.enemies.sprites(): if hitbox.colliderect(enemy.rect): hit = True break - self.field.kill_if_not_colliding(self.enemies.sprites) return hit def set_direction(self): |