summaryrefslogtreecommitdiff
path: root/src/sliceitoff/game/gameplay.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/game/gameplay.py')
-rw-r--r--src/sliceitoff/game/gameplay.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/sliceitoff/game/gameplay.py b/src/sliceitoff/game/gameplay.py
index e691b84..12daeaf 100644
--- a/src/sliceitoff/game/gameplay.py
+++ b/src/sliceitoff/game/gameplay.py
@@ -17,7 +17,18 @@ class Gameplay:
self.enemies = enemies
def fire(self):
- if self.player.fire_lazer():
+ hitbox = self.field.slice(
+ self.player.position,
+ self.player.direction,
+ 4_500)
+ hit = False
+ if hitbox is not None:
+ for enemy in self.enemies.sprites():
+ if hitbox.colliderect(enemy.rect):
+ hit = True
+ break
+
+ if hit:
if Stats.lose_life():
return True
self.field.kill_if_not_colliding(self.enemies.sprites())
@@ -33,14 +44,14 @@ class Gameplay:
for event in pygame.event.get():
match event.type:
case pygame.MOUSEMOTION:
- self.player.set_position(pygame.mouse.get_pos())
+ self.player.update(pos = pygame.mouse.get_pos())
case pygame.MOUSEBUTTONDOWN:
- self.player.set_position(pygame.mouse.get_pos())
+ self.player.update(pos = pygame.mouse.get_pos())
if event.button == 1:
if self.fire():
return True
if event.button == 3:
- self.player.set_direction()
+ self.player.update(direction = True)
case pygame.KEYDOWN:
match event.key:
case pygame.K_ESCAPE | pygame.K_q: