Start and stop some sounds and add a little bit of reverb to sounds so they fit the 'dungeon' theme.

master
Zed A. Shaw 1 week ago
parent a8ae6df13b
commit 25d782df6d
  1. 2
      assets/enemies.json
  2. BIN
      assets/sounds/Creature_Sounds-Creature_Death_1.ogg
  3. BIN
      assets/sounds/Creature_Sounds-Evil_Eye_Sound_1.ogg
  4. BIN
      assets/sounds/Creature_Sounds-Evil_Eye_Sound_2.ogg
  5. BIN
      assets/sounds/Creature_Sounds-Giant_Voice_1.ogg
  6. BIN
      assets/sounds/Creature_Sounds-Humanoid_Death_1.ogg
  7. BIN
      assets/sounds/Creature_Sounds-Medium_Rat.ogg
  8. BIN
      assets/sounds/Creature_Sounds-Ranger_1.ogg
  9. BIN
      assets/sounds/Creature_Sounds-Small_Rat.ogg
  10. BIN
      assets/sounds/Creature_Sounds-Spider_1-001.ogg
  11. BIN
      assets/sounds/Creature_Sounds-Spider_1-002.ogg
  12. BIN
      assets/sounds/Creature_Sounds-Sword_Hit_1.ogg
  13. BIN
      assets/sounds/Creature_Sounds-Sword_Hit_2.ogg
  14. BIN
      assets/sounds/Creature_Sounds-Walk.ogg
  15. 5
      gui_fsm.cpp
  16. 13
      sound.cpp
  17. 1
      sound.hpp
  18. 1
      systems.cpp

@ -36,7 +36,7 @@
{"_type": "EnemyConfig", "hearing_distance": 5}, {"_type": "EnemyConfig", "hearing_distance": 5},
{"_type": "Sprite", "name": "axe_ranger"}, {"_type": "Sprite", "name": "axe_ranger"},
{"_type": "Animation", "scale": 0.1, "simple": false, "frames": 10, "speed": 0.6}, {"_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": { "EVIL_EYE": {

@ -123,6 +123,8 @@ namespace gui {
void FSM::IDLE(Event ev) { void FSM::IDLE(Event ev) {
using enum Event; using enum Event;
sound::stop("walk");
switch(ev) { switch(ev) {
case QUIT: case QUIT:
$window.close(); $window.close();
@ -164,7 +166,7 @@ namespace gui {
dbc::log("Nothing to close."); dbc::log("Nothing to close.");
break; break;
case STAIRS_DOWN: case STAIRS_DOWN:
// $main_ui.show_level(); sound::stop("ambient");
state(State::NEXT_LEVEL); state(State::NEXT_LEVEL);
break; break;
case STOP_COMBAT: case STOP_COMBAT:
@ -181,6 +183,7 @@ namespace gui {
switch(ev) { switch(ev) {
case STAIRS_DOWN: case STAIRS_DOWN:
sound::play("ambient");
next_level(); next_level();
state(State::IDLE); state(State::IDLE);
default: default:

@ -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) { void play_at(const std::string name, float x, float y, float z) {
dbc::check(initialized, "You need to call sound::init() first"); dbc::check(initialized, "You need to call sound::init() first");
if(SMGR.sounds.contains(name)) { if(SMGR.sounds.contains(name)) {

@ -19,5 +19,6 @@ namespace sound {
void load(const std::string name, const std::string path); void load(const std::string name, const std::string path);
void play(const std::string name, bool loop=false); void play(const std::string name, bool loop=false);
void play_at(const std::string name, float x, float y, float z); void play_at(const std::string name, float x, float y, float z);
void stop(const std::string name);
void mute(bool setting); void mute(bool setting);
} }

@ -135,6 +135,7 @@ void System::death(GameLevel &level, components::ComponentMap& components) {
world.remove<Animation>(ent); world.remove<Animation>(ent);
if(auto snd = world.get_if<Sound>(ent)) { if(auto snd = world.get_if<Sound>(ent)) {
sound::stop(snd->attack);
sound::play(snd->death); sound::play(snd->death);
} }

Loading…
Cancel
Save