A couple of small adjustments to level 12 and 13. Added the ability to lock levels meaning all enemies must be defeated before you can pass the right boundary. Raised the volume level of coffins a bit. Fixed hunter style attack patterns.
This commit is contained in:
60
src/enemy.py
60
src/enemy.py
@@ -53,47 +53,11 @@ class Enemy(Object):
|
||||
return self._currentX
|
||||
|
||||
@xPos.setter
|
||||
|
||||
def xPos(self, value):
|
||||
"""Set current x position"""
|
||||
self._currentX = value
|
||||
|
||||
def update_movement(self, player):
|
||||
"""Update enemy movement based on attack pattern"""
|
||||
if self.attackPattern['type'] == 'hunter':
|
||||
# Calculate distance to player
|
||||
distanceToPlayer = player.xPos - self.xPos
|
||||
|
||||
if abs(distanceToPlayer) <= (self.patrolEnd - self.patrolStart): # Use full range
|
||||
# Player is within movement range
|
||||
if self.movingRight:
|
||||
# Moving right
|
||||
if distanceToPlayer < -self.turnThreshold:
|
||||
# Player is too far behind us, turn around
|
||||
self.movingRight = False
|
||||
else:
|
||||
self.xPos += self.movementSpeed
|
||||
else:
|
||||
# Moving left
|
||||
if distanceToPlayer > self.turnThreshold:
|
||||
# Player is too far ahead of us, turn around
|
||||
self.movingRight = True
|
||||
else:
|
||||
self.xPos -= self.movementSpeed
|
||||
|
||||
# Ensure we stay within our range
|
||||
if self.xPos <= self.patrolStart:
|
||||
self.xPos = self.patrolStart
|
||||
self.movingRight = True
|
||||
elif self.xPos >= self.patrolEnd:
|
||||
self.xPos = self.patrolEnd
|
||||
self.movingRight = False
|
||||
else:
|
||||
# Player out of range, return to normal patrol
|
||||
self.patrol_movement()
|
||||
else:
|
||||
# Default patrol behavior
|
||||
self.patrol_movement()
|
||||
|
||||
def patrol_movement(self):
|
||||
"""Standard back-and-forth patrol movement"""
|
||||
if self.movingRight:
|
||||
@@ -109,20 +73,28 @@ class Enemy(Object):
|
||||
"""Update enemy position and handle attacks"""
|
||||
if not self.isActive or self.health <= 0:
|
||||
return
|
||||
|
||||
# Handle movement based on enemy type
|
||||
if self.enemyType == "zombie":
|
||||
# Zombies always chase player
|
||||
|
||||
# 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 player.xPos > self.xPos:
|
||||
self.movingRight = True
|
||||
self.xPos += self.movementSpeed
|
||||
else:
|
||||
self.movingRight = False
|
||||
self.xPos -= self.movementSpeed
|
||||
|
||||
# Only enforce level boundaries, not patrol boundaries
|
||||
if self.xPos < self.level.leftBoundary:
|
||||
self.xPos = self.level.leftBoundary
|
||||
self.movingRight = True
|
||||
elif self.xPos > self.level.rightBoundary:
|
||||
self.xPos = self.level.rightBoundary
|
||||
self.movingRight = False
|
||||
else:
|
||||
# Other enemies use their attack pattern
|
||||
self.update_movement(player)
|
||||
|
||||
# Other enemies 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