Level updates. Fixed a bug with hunting enemies. Boosted sound for headless horseman.
This commit is contained in:
18
src/enemy.py
18
src/enemy.py
@@ -5,6 +5,8 @@ import pygame
|
||||
|
||||
class Enemy(Object):
|
||||
def __init__(self, xRange, y, enemyType, sounds, level, **kwargs):
|
||||
# Track when critters should start hunting
|
||||
self.hunting = False
|
||||
# Initialize base object properties
|
||||
super().__init__(
|
||||
xRange,
|
||||
@@ -73,10 +75,16 @@ class Enemy(Object):
|
||||
"""Update enemy position and handle attacks"""
|
||||
if not self.isActive or self.health <= 0:
|
||||
return
|
||||
|
||||
|
||||
# Check if player has entered territory
|
||||
if not self.hunting:
|
||||
if self.patrolStart <= player.xPos <= self.patrolEnd:
|
||||
self.hunting = True
|
||||
|
||||
# Handle movement based on enemy type and pattern
|
||||
if self.enemyType == "zombie" or self.attackPattern['type'] == 'hunter':
|
||||
# Direct chase behavior for zombies and hunters
|
||||
if (self.enemyType == "zombie" or
|
||||
(self.attackPattern['type'] == 'hunter' and self.hunting)):
|
||||
# Direct chase behavior for zombies and activated hunters
|
||||
if player.xPos > self.xPos:
|
||||
self.movingRight = True
|
||||
self.xPos += self.movementSpeed
|
||||
@@ -92,9 +100,9 @@ class Enemy(Object):
|
||||
self.xPos = self.level.rightBoundary
|
||||
self.movingRight = False
|
||||
else:
|
||||
# Other enemies use patrol pattern
|
||||
# Other enemies and non-activated hunters use patrol pattern
|
||||
self.patrol_movement()
|
||||
|
||||
|
||||
# Check for attack opportunity
|
||||
if self.can_attack(currentTime, player):
|
||||
self.attack(currentTime, player)
|
||||
|
Reference in New Issue
Block a user