summaryrefslogtreecommitdiff
path: root/src/sliceitoff/player/player.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-16 20:30:32 +0200
committerViljami Ilola <+@hix.fi>2024-03-16 20:30:32 +0200
commit3959cfd0c0cab47f863ea5672350ad280b4b7773 (patch)
tree1aff8e0cad45be393802774b4c011468c8cfc161 /src/sliceitoff/player/player.py
parent6a9f8ab2b47ab9dd19b7ae0e507c16bb919de975 (diff)
field remove
Diffstat (limited to 'src/sliceitoff/player/player.py')
-rw-r--r--src/sliceitoff/player/player.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/sliceitoff/player/player.py b/src/sliceitoff/player/player.py
index e9cb569..a7d2b63 100644
--- a/src/sliceitoff/player/player.py
+++ b/src/sliceitoff/player/player.py
@@ -14,8 +14,9 @@ class PlayerSprite(pygame.sprite.Sprite):
self.rect = self.image.get_rect().move(x,y)
class Player():
- def __init__(self, field = None):
+ def __init__(self, field = None, enemies = None):
self.field = field
+ self.enemies = enemies
self.position = (20_000, 14_000)
self.direction = False
self.lazer = False
@@ -43,10 +44,21 @@ class Player():
self.__update_sprites()
return self.sprites
- def set_lazer(self):
+ def fire_lazer(self):
# self.lazer = True
# self.updated = True
- self.field.slice(self.position, self.direction, 1_000)
+ hitbox = self.field.slice(self.position, self.direction, 1_000)
+ if hitbox is not None:
+ for enemy in self.enemies.sprites:
+ if hitbox.colliderect(enemy.rect):
+ return True
+ for field in self.field.sprites:
+ for enemy in self.enemies.sprites:
+ if enemy.rect.colliderect(field.rect):
+ break
+ else:
+ field.remove(self.field.sprites)
+ return False
def set_direction(self):
if not self.lazer: