2023-10-04 02:37:28 +00:00
|
|
|
import os
|
|
|
|
import pygame
|
|
|
|
|
|
|
|
from configs.game.monster_config import monster_data
|
|
|
|
|
|
|
|
|
|
|
|
class AudioHandler:
|
|
|
|
|
|
|
|
def __init__(self, sprite_type, monster_name=None):
|
|
|
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
asset_path = os.path.join(
|
2023-11-14 21:44:43 +00:00
|
|
|
script_dir, '../..', 'assets', 'audio')
|
2023-10-04 02:37:28 +00:00
|
|
|
|
|
|
|
if sprite_type == 'player':
|
|
|
|
pass
|
|
|
|
|
|
|
|
elif sprite_type == 'enemy':
|
|
|
|
|
|
|
|
# Sounds
|
|
|
|
self.attack_sound = pygame.mixer.Sound(
|
|
|
|
monster_data[monster_name]['attack_sound'])
|
|
|
|
self.death_sound = pygame.mixer.Sound(
|
|
|
|
f'{asset_path}/death.wav')
|
|
|
|
self.hit_sound = pygame.mixer.Sound(f'{asset_path}/hit.wav')
|
|
|
|
self.death_sound.set_volume(0.2)
|
|
|
|
self.hit_sound.set_volume(0.2)
|
|
|
|
self.attack_sound.set_volume(0.2)
|