Quick little fix to add a blank sound for placeholders.
This commit is contained in:
parent
3720340ab7
commit
6e56de08c5
4 changed files with 20 additions and 11 deletions
BIN
assets/blank.ogg
Normal file
BIN
assets/blank.ogg
Normal file
Binary file not shown.
|
@ -3,7 +3,8 @@
|
||||||
"sword_1": "assets/sword.1.ogg",
|
"sword_1": "assets/sword.1.ogg",
|
||||||
"monster_16": "assets/monster-16.ogg",
|
"monster_16": "assets/monster-16.ogg",
|
||||||
"monster_1": "assets/monster-1.ogg",
|
"monster_1": "assets/monster-1.ogg",
|
||||||
"step_leather_1": "assets/step_leather_1.ogg"
|
"walk": "assets/blank.ogg",
|
||||||
|
"blank": "assets/blank.ogg"
|
||||||
},
|
},
|
||||||
"sprites": {
|
"sprites": {
|
||||||
"armored_knight": "assets/armored_knight_1-256.png",
|
"armored_knight": "assets/armored_knight_1-256.png",
|
||||||
|
|
|
@ -202,8 +202,7 @@ namespace gui {
|
||||||
Point move_to = $main_ui.plan_move(dir, strafe);
|
Point move_to = $main_ui.plan_move(dir, strafe);
|
||||||
|
|
||||||
if($level.map->can_move(move_to) && !$level.collision->occupied(move_to)) {
|
if($level.map->can_move(move_to) && !$level.collision->occupied(move_to)) {
|
||||||
fmt::println("PLAYING WALK");
|
sound::play("walk");
|
||||||
sound::play("step_leather_1");
|
|
||||||
state(MOVING);
|
state(MOVING);
|
||||||
} else {
|
} else {
|
||||||
state(IDLE);
|
state(IDLE);
|
||||||
|
|
25
sound.cpp
25
sound.cpp
|
@ -38,17 +38,26 @@ namespace sound {
|
||||||
|
|
||||||
void play(const std::string name) {
|
void play(const std::string name) {
|
||||||
dbc::check(initialized, "You need to call sound::init() first");
|
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));
|
if(SMGR.sounds.contains(name)) {
|
||||||
// get the sound from the sound map
|
// get the sound from the sound map
|
||||||
auto pair = SMGR.sounds.at(name);
|
auto pair = SMGR.sounds.at(name);
|
||||||
// play it
|
// play it
|
||||||
pair.sound->play();
|
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) {
|
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");
|
||||||
auto pair = SMGR.sounds.at(name);
|
if(SMGR.sounds.contains(name)) {
|
||||||
pair.sound->setPosition({x, y, z});
|
auto pair = SMGR.sounds.at(name);
|
||||||
pair.sound->play();
|
pair.sound->setPosition({x, y, z});
|
||||||
|
pair.sound->play();
|
||||||
|
} else {
|
||||||
|
dbc::log(fmt::format("Attempted to play_at {} sound but not available.",
|
||||||
|
name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue