diff --git a/assets/enemies.json b/assets/enemies.json index 296dd06..5befe3d 100644 --- a/assets/enemies.json +++ b/assets/enemies.json @@ -36,7 +36,7 @@ {"_type": "EnemyConfig", "hearing_distance": 5}, {"_type": "Sprite", "name": "axe_ranger"}, {"_type": "Animation", "scale": 0.1, "simple": false, "frames": 10, "speed": 0.6}, - {"_type": "Sound", "attack": "Sword_Hit_1", "death": "Humanoid_Death_1"} + {"_type": "Sound", "attack": "Sword_Hit_1", "death": "Ranger_1"} ] }, "EVIL_EYE": { diff --git a/assets/sounds/Creature_Sounds-Creature_Death_1.ogg b/assets/sounds/Creature_Sounds-Creature_Death_1.ogg index 99239c9..baec93b 100644 Binary files a/assets/sounds/Creature_Sounds-Creature_Death_1.ogg and b/assets/sounds/Creature_Sounds-Creature_Death_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg b/assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg index a55ae8a..62f1169 100644 Binary files a/assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg and b/assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg b/assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg index 6f05509..dad290b 100644 Binary files a/assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg and b/assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg differ diff --git a/assets/sounds/Creature_Sounds-Giant_Voice_1.ogg b/assets/sounds/Creature_Sounds-Giant_Voice_1.ogg index f14f479..526dcd1 100644 Binary files a/assets/sounds/Creature_Sounds-Giant_Voice_1.ogg and b/assets/sounds/Creature_Sounds-Giant_Voice_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg b/assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg index 08760fa..64a0fc8 100644 Binary files a/assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg and b/assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Medium_Rat.ogg b/assets/sounds/Creature_Sounds-Medium_Rat.ogg index 1136186..ddd50fc 100644 Binary files a/assets/sounds/Creature_Sounds-Medium_Rat.ogg and b/assets/sounds/Creature_Sounds-Medium_Rat.ogg differ diff --git a/assets/sounds/Creature_Sounds-Ranger_1.ogg b/assets/sounds/Creature_Sounds-Ranger_1.ogg index 4af36f3..1df01ec 100644 Binary files a/assets/sounds/Creature_Sounds-Ranger_1.ogg and b/assets/sounds/Creature_Sounds-Ranger_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Small_Rat.ogg b/assets/sounds/Creature_Sounds-Small_Rat.ogg index 08200c2..c0b00ed 100644 Binary files a/assets/sounds/Creature_Sounds-Small_Rat.ogg and b/assets/sounds/Creature_Sounds-Small_Rat.ogg differ diff --git a/assets/sounds/Creature_Sounds-Spider_1-001.ogg b/assets/sounds/Creature_Sounds-Spider_1-001.ogg index ef917f6..278c810 100644 Binary files a/assets/sounds/Creature_Sounds-Spider_1-001.ogg and b/assets/sounds/Creature_Sounds-Spider_1-001.ogg differ diff --git a/assets/sounds/Creature_Sounds-Spider_1-002.ogg b/assets/sounds/Creature_Sounds-Spider_1-002.ogg index 54cc4db..22a9f16 100644 Binary files a/assets/sounds/Creature_Sounds-Spider_1-002.ogg and b/assets/sounds/Creature_Sounds-Spider_1-002.ogg differ diff --git a/assets/sounds/Creature_Sounds-Sword_Hit_1.ogg b/assets/sounds/Creature_Sounds-Sword_Hit_1.ogg index fa367e6..1737843 100644 Binary files a/assets/sounds/Creature_Sounds-Sword_Hit_1.ogg and b/assets/sounds/Creature_Sounds-Sword_Hit_1.ogg differ diff --git a/assets/sounds/Creature_Sounds-Sword_Hit_2.ogg b/assets/sounds/Creature_Sounds-Sword_Hit_2.ogg index fc095be..e3fb6fd 100644 Binary files a/assets/sounds/Creature_Sounds-Sword_Hit_2.ogg and b/assets/sounds/Creature_Sounds-Sword_Hit_2.ogg differ diff --git a/assets/sounds/Creature_Sounds-Walk.ogg b/assets/sounds/Creature_Sounds-Walk.ogg index dfa8860..f7f3686 100644 Binary files a/assets/sounds/Creature_Sounds-Walk.ogg and b/assets/sounds/Creature_Sounds-Walk.ogg differ diff --git a/gui_fsm.cpp b/gui_fsm.cpp index 95b5e05..8016540 100644 --- a/gui_fsm.cpp +++ b/gui_fsm.cpp @@ -123,6 +123,8 @@ namespace gui { void FSM::IDLE(Event ev) { using enum Event; + sound::stop("walk"); + switch(ev) { case QUIT: $window.close(); @@ -164,7 +166,7 @@ namespace gui { dbc::log("Nothing to close."); break; case STAIRS_DOWN: - // $main_ui.show_level(); + sound::stop("ambient"); state(State::NEXT_LEVEL); break; case STOP_COMBAT: @@ -181,6 +183,7 @@ namespace gui { switch(ev) { case STAIRS_DOWN: + sound::play("ambient"); next_level(); state(State::IDLE); default: diff --git a/sound.cpp b/sound.cpp index 141369e..4afd135 100644 --- a/sound.cpp +++ b/sound.cpp @@ -53,6 +53,19 @@ namespace sound { } } + void stop(const std::string name) { + dbc::check(initialized, "You need to call sound::init() first"); + + if(SMGR.sounds.contains(name)) { + // get the sound from the sound map + auto pair = SMGR.sounds.at(name); + pair.sound->stop(); + } else { + dbc::log(fmt::format("Attempted to stop {} sound but not available.", + name)); + } + } + void play_at(const std::string name, float x, float y, float z) { dbc::check(initialized, "You need to call sound::init() first"); if(SMGR.sounds.contains(name)) { diff --git a/sound.hpp b/sound.hpp index 3f3bd98..9a8b4eb 100644 --- a/sound.hpp +++ b/sound.hpp @@ -19,5 +19,6 @@ namespace sound { void load(const std::string name, const std::string path); void play(const std::string name, bool loop=false); void play_at(const std::string name, float x, float y, float z); + void stop(const std::string name); void mute(bool setting); } diff --git a/systems.cpp b/systems.cpp index 464b37e..35acbba 100644 --- a/systems.cpp +++ b/systems.cpp @@ -135,6 +135,7 @@ void System::death(GameLevel &level, components::ComponentMap& components) { world.remove(ent); if(auto snd = world.get_if(ent)) { + sound::stop(snd->attack); sound::play(snd->death); }