Sounds are working...BUT...I have to make ones I own so hang on until I do that.
This commit is contained in:
parent
7309ec2f40
commit
268d8abf52
5 changed files with 75 additions and 11 deletions
40
gui.cpp
40
gui.cpp
|
@ -13,12 +13,28 @@
|
|||
#include "ftxui/component/loop.hpp" // for Loop
|
||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||
#include <vector>
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
using namespace ftxui;
|
||||
using namespace std;
|
||||
using namespace fmt;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void load_sound(sf::Sound &sound, sf::SoundBuffer &buffer, const char *in_file) {
|
||||
if(!buffer.loadFromFile(in_file)) {
|
||||
fmt::println("Failed to load {}", in_file);
|
||||
}
|
||||
|
||||
sound.setBuffer(buffer);
|
||||
}
|
||||
|
||||
GUI::GUI() {
|
||||
load_sound(you_died_sound, you_died_buffer, "./assets/you_died.wav");
|
||||
load_sound(build_works_sound, build_works_buffer, "./assets/build_works.wav");
|
||||
load_sound(build_failed_sound, build_failed_buffer, "./assets/build_failed.wav");
|
||||
load_sound(building_sound, building_buffer, "./assets/building.wav");
|
||||
}
|
||||
|
||||
void GUI::output(const string &msg) {
|
||||
lines.push_back(msg);
|
||||
}
|
||||
|
@ -98,3 +114,27 @@ int GUI::main_loop(GameEngine &game, std::function<bool()> runner) {
|
|||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void GUI::build_works() {
|
||||
building_sound.stop();
|
||||
build_works_sound.play();
|
||||
output("BUILD FINISHED!");
|
||||
}
|
||||
|
||||
void GUI::build_failed(const string &command) {
|
||||
building_sound.stop();
|
||||
build_failed_sound.play();
|
||||
output(format("!!! BUILD FAILED. Your command correct? '{}'", command));
|
||||
}
|
||||
|
||||
void GUI::you_died() {
|
||||
building_sound.stop();
|
||||
you_died_sound.play();
|
||||
output("YOU DIED!");
|
||||
}
|
||||
|
||||
void GUI::building() {
|
||||
output("############# START ############");
|
||||
output(">>>> Will it Build?");
|
||||
building_sound.play();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue