Stats tracking updated. Work on skull storms. Enemy death sound added for goblins. Various updates and fixes.
This commit is contained in:
17
src/enemy.py
17
src/enemy.py
@@ -4,18 +4,19 @@ import pygame
|
||||
|
||||
|
||||
class Enemy(Object):
|
||||
def __init__(self, xRange, y, enemyType, sounds, **kwargs):
|
||||
def __init__(self, xRange, y, enemyType, sounds, level, **kwargs):
|
||||
# Initialize base object properties
|
||||
super().__init__(
|
||||
xRange,
|
||||
y,
|
||||
f"{enemyType}", # Base sound for ambient noise
|
||||
f"{enemyType}", # Base sound
|
||||
isStatic=False,
|
||||
isHazard=True
|
||||
)
|
||||
|
||||
# Enemy specific properties
|
||||
self.enemyType = enemyType
|
||||
self.level = level
|
||||
self.health = kwargs.get('health', 5) # Default 5 HP
|
||||
self.damage = kwargs.get('damage', 1) # Default 1 damage
|
||||
self.attackRange = kwargs.get('attack_range', 1) # Default 1 tile range
|
||||
@@ -106,7 +107,7 @@ class Enemy(Object):
|
||||
self.sounds[attackSound].play()
|
||||
# Deal damage to player
|
||||
player.set_health(player.get_health() - self.damage)
|
||||
speak(f"The {self.enemyType} hits you!")
|
||||
self.sounds['player_takes_damage'].play()
|
||||
|
||||
def take_damage(self, amount):
|
||||
"""Handle enemy taking damage"""
|
||||
@@ -120,7 +121,11 @@ class Enemy(Object):
|
||||
if self.channel:
|
||||
obj_stop(self.channel)
|
||||
self.channel = None
|
||||
# Play death sound if available
|
||||
deathSound = f"{self.enemyType}_death"
|
||||
# Play death sound if available using positional audio
|
||||
deathSound = f"{self.enemyType}_dies"
|
||||
if deathSound in self.sounds:
|
||||
self.sounds[deathSound].play()
|
||||
self.channel = obj_play(self.sounds, deathSound, self.level.player.xPos, self.xPos, loop=False)
|
||||
|
||||
# Update stats
|
||||
self.level.player.stats.update_stat('Enemies killed', 1)
|
||||
self.level.player.stats.update_stat('Enemies remaining', -1)
|
||||
|
Reference in New Issue
Block a user