Boss fight looking better, but I need to get this bounce animation in the main game fights.

This commit is contained in:
Zed A. Shaw 2025-02-28 13:03:13 -05:00
parent 25d782df6d
commit 2d790c5986
8 changed files with 54 additions and 35 deletions

View file

@ -12,6 +12,20 @@ namespace sound {
using std::make_shared;
namespace fs = std::filesystem;
SoundPair& get_sound_pair(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
return SMGR.sounds.at(name);
} else {
dbc::log(fmt::format("Attempted to stop {} sound but not available.",
name));
return SMGR.sounds.at("blank");
}
}
void init() {
if(!initialized) {
Config assets("assets/config.json");
@ -38,44 +52,28 @@ namespace sound {
}
void play(const std::string name, bool loop) {
dbc::check(initialized, "You need to call sound::init() first");
if(muted) return;
if(SMGR.sounds.contains(name)) {
// get the sound from the sound map
auto pair = SMGR.sounds.at(name);
pair.sound->setLooping(loop);
// play it
pair.sound->play();
} else {
dbc::log(fmt::format("Attempted to play {} sound but not available.",
name));
}
auto& pair = get_sound_pair(name);
pair.sound->setLooping(loop);
// play it
pair.sound->play();
}
void stop(const std::string name) {
dbc::check(initialized, "You need to call sound::init() first");
auto& pair = get_sound_pair(name);
pair.sound->stop();
}
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));
}
bool playing(const std::string name) {
auto& pair = get_sound_pair(name);
auto status = pair.sound->getStatus();
return status == sf::SoundSource::Status::Playing;
}
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)) {
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));
}
auto& pair = get_sound_pair(name);
pair.sound->setPosition({x, y, z});
pair.sound->play();
}
void mute(bool setting) {