diff --git a/assets/blank.ogg b/assets/blank.ogg new file mode 100644 index 0000000..3322d4b Binary files /dev/null and b/assets/blank.ogg differ diff --git a/assets/config.json b/assets/config.json index fa9e72c..b062809 100644 --- a/assets/config.json +++ b/assets/config.json @@ -3,7 +3,8 @@ "sword_1": "assets/sword.1.ogg", "monster_16": "assets/monster-16.ogg", "monster_1": "assets/monster-1.ogg", - "step_leather_1": "assets/step_leather_1.ogg" + "walk": "assets/blank.ogg", + "blank": "assets/blank.ogg" }, "sprites": { "armored_knight": "assets/armored_knight_1-256.png", diff --git a/gui_fsm.cpp b/gui_fsm.cpp index 9c77b9e..e74c866 100644 --- a/gui_fsm.cpp +++ b/gui_fsm.cpp @@ -202,8 +202,7 @@ namespace gui { Point move_to = $main_ui.plan_move(dir, strafe); if($level.map->can_move(move_to) && !$level.collision->occupied(move_to)) { - fmt::println("PLAYING WALK"); - sound::play("step_leather_1"); + sound::play("walk"); state(MOVING); } else { state(IDLE); diff --git a/sound.cpp b/sound.cpp index d278ec3..f3b381a 100644 --- a/sound.cpp +++ b/sound.cpp @@ -38,17 +38,26 @@ namespace sound { void play(const std::string name) { dbc::check(initialized, "You need to call sound::init() first"); - dbc::check(SMGR.sounds.contains(name), fmt::format("sound {} is not loaded in map", name)); - // get the sound from the sound map - auto pair = SMGR.sounds.at(name); - // play it - pair.sound->play(); + if(SMGR.sounds.contains(name)) { + // get the sound from the sound map + auto pair = SMGR.sounds.at(name); + // play it + pair.sound->play(); + } else { + dbc::log(fmt::format("Attempted to play {} 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"); - auto pair = SMGR.sounds.at(name); - pair.sound->setPosition({x, y, z}); - pair.sound->play(); + if(SMGR.sounds.contains(name)) { + auto pair = SMGR.sounds.at(name); + pair.sound->setPosition({x, y, z}); + pair.sound->play(); + } else { + dbc::log(fmt::format("Attempted to play_at {} sound but not available.", + name)); + } } }