Level updates. Fixed a bug with hunting enemies. Boosted sound for headless horseman.
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
"y": 0,
|
||||
"type": "catapult",
|
||||
"fire_interval": 3000,
|
||||
"range": 40
|
||||
"range": 30
|
||||
},
|
||||
{
|
||||
"x_range": [55, 60],
|
||||
@@ -56,7 +56,7 @@
|
||||
"y": 0,
|
||||
"type": "catapult",
|
||||
"fire_interval": 3000,
|
||||
"range": 40
|
||||
"range": 30
|
||||
},
|
||||
{
|
||||
"x_range": [105, 110],
|
||||
@@ -86,7 +86,7 @@
|
||||
"y": 0,
|
||||
"type": "catapult",
|
||||
"fire_interval": 3000,
|
||||
"range": 40
|
||||
"range": 30
|
||||
},
|
||||
{
|
||||
"x_range": [145, 165],
|
||||
@@ -117,7 +117,7 @@
|
||||
"y": 0,
|
||||
"type": "catapult",
|
||||
"fire_interval": 3000,
|
||||
"range": 40
|
||||
"range": 30
|
||||
},
|
||||
{
|
||||
"x_range": [185, 195],
|
||||
@@ -148,7 +148,7 @@
|
||||
"y": 0,
|
||||
"type": "catapult",
|
||||
"fire_interval": 3000,
|
||||
"range": 40
|
||||
"range": 30
|
||||
},
|
||||
{
|
||||
"x_range": [235, 240],
|
||||
@@ -169,7 +169,7 @@
|
||||
"y": 0,
|
||||
"type": "catapult",
|
||||
"fire_interval": 3000,
|
||||
"range": 40
|
||||
"range": 30
|
||||
},
|
||||
{
|
||||
"x_range": [265, 285],
|
||||
@@ -194,7 +194,7 @@
|
||||
"y": 0,
|
||||
"type": "catapult",
|
||||
"fire_interval": 3000,
|
||||
"range": 40
|
||||
"range": 30
|
||||
},
|
||||
{
|
||||
"x_range": [305, 315],
|
||||
@@ -220,7 +220,7 @@
|
||||
"y": 0,
|
||||
"type": "catapult",
|
||||
"fire_interval": 3000,
|
||||
"range": 40
|
||||
"range": 30
|
||||
},
|
||||
{
|
||||
"x_range": [355, 375],
|
||||
|
@@ -307,34 +307,25 @@
|
||||
"x_range": [405, 495],
|
||||
"y": 0,
|
||||
"enemy_type": "witch",
|
||||
"health": 500,
|
||||
"health": 50,
|
||||
"damage": 3,
|
||||
"attack_range": 2,
|
||||
"attack_pattern": {
|
||||
"type": "hunter",
|
||||
"turn_threshold": 3
|
||||
"type": "patrol"
|
||||
}
|
||||
},
|
||||
{
|
||||
"x_range": [405, 495],
|
||||
"y": 0,
|
||||
"enemy_type": "boogie_man",
|
||||
"health": 500,
|
||||
"enemy_type": "headless_horseman",
|
||||
"health": 100,
|
||||
"damage": 3,
|
||||
"attack_range": 2,
|
||||
"attack_range": 3,
|
||||
"attack_pattern": {
|
||||
"type": "hunter",
|
||||
"turn_threshold": 3
|
||||
"turn_threshold": 15
|
||||
}
|
||||
},
|
||||
{
|
||||
"x": 450,
|
||||
"y": 0,
|
||||
"type": "grave",
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 100
|
||||
},
|
||||
{
|
||||
"x_range": [455, 460],
|
||||
"y": 3,
|
||||
@@ -359,14 +350,6 @@
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 490,
|
||||
"y": 0,
|
||||
"type": "grave",
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 100
|
||||
}
|
||||
],
|
||||
"boundaries": {
|
||||
|
BIN
sounds/headless_horseman.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/headless_horseman.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/headless_horseman_dies.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/headless_horseman_dies.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
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