Have a basic little click sound going, but hover events will need some work. I'm doing those on every mouse move.

This commit is contained in:
Zed A. Shaw 2025-04-15 11:38:38 -04:00
parent 7186c2ecb0
commit 2ecef8d9f9
6 changed files with 36 additions and 11 deletions

View file

@ -1,5 +1,6 @@
#include "guecs.hpp"
#include "shaders.hpp"
#include "sound.hpp"
namespace guecs {
@ -58,6 +59,14 @@ namespace guecs {
bar.init(cell);
}
void Sound::play(bool hover) {
if(hover) {
// BUG: need to sort out how to make hover a one shot thing
// sound::play(on_hover);
} else {
sound::play(on_click);
}
}
void Background::init() {
sf::Vector2f size{float(w), float(h)};
@ -232,6 +241,12 @@ namespace guecs {
effect.run();
}
if($world.has<Sound>(ent)) {
auto& sound = $world.get<Sound>(ent);
sound.play(hover);
}
if(hover) return; // kinda gross
if(auto action_data = get_if<ActionData>(ent)) {