Get the build fail to actually play and keep the building sound looping until the build is done.

master
Zed A. Shaw 3 months ago
parent 2035a6dd00
commit 95cd84b09d
  1. 2
      builder.cpp
  2. 2
      fsm.hpp
  3. 3
      game_engine.cpp
  4. 1
      game_engine.hpp
  5. 2
      gui.cpp
  6. 3
      sfmlbackend.cpp
  7. 2
      sfmlbackend.hpp
  8. 2
      status.txt

@ -87,7 +87,6 @@ void Builder::BUILDING(BuildEvent ev) {
}
build_out = NULL;
game.event(GameEvent::BUILD_DONE);
state(BuildState::DONE);
} else {
auto m = parse_line(line);
@ -171,6 +170,7 @@ void Builder::DONE(BuildEvent ev) {
gui.you_died();
}
game.event(GameEvent::BUILD_DONE);
listener->reset_state();
gui.output("^^^^^^^^^^^ END ^^^^^^^^^^^");
state(BuildState::WAITING);

@ -18,7 +18,7 @@ public:
template<typename... Types>
void event(E event, Types... args);
void state(S next_state) {
void state(S next_state)
_state = next_state;
}

@ -3,6 +3,7 @@
#include <iostream>
#include <fmt/core.h>
#include <fmt/color.h>
#define FSM_DEBUG 1
#include "game_engine.hpp"
#include <cassert>
#include "dbc.hpp"
@ -14,7 +15,7 @@ using namespace std;
GameEngine::GameEngine(int hp) : starting_hp(hp) {
hit_points = max_hp();
};
}
int GameEngine::determine_damage(string &type) {
try {

@ -13,7 +13,6 @@ enum class GameState {
START, IDLE, IN_ROUND, DEAD, SUCCESS, FAILURE
};
enum class GameEvent {
BUILD_START, BUILD_SUCCESS,
BUILD_DONE, BUILD_FAILED, HIT

@ -25,7 +25,7 @@ GUI::GUI() {
you_died_sound.load(data, "you_died");
build_works_sound.load(data, "build_works");
build_failed_sound.load(data, "build_failed");
building_sound.load(data, "building");
building_sound.load(data, "building", true);
}
void GUI::output(const string msg) {

@ -17,7 +17,7 @@ using namespace nlohmann;
using namespace ImGui;
using std::string;
void SoundQuip::load(json &data, const char *file_key) {
void SoundQuip::load(json &data, const char *file_key, bool loop) {
auto audio = data["audio"];
json::string_t file_name = audio[file_key].template get<string>();
@ -26,6 +26,7 @@ void SoundQuip::load(json &data, const char *file_key) {
}
sound.setBuffer(buffer);
sound.setLoop(loop);
}
void SoundQuip::play() {

@ -25,7 +25,7 @@ public:
SoundQuip() {};
void load(nlohmann::json &data, const char *in_file);
void load(nlohmann::json &data, const char *file_key, bool loop=false);
void play();
void stop();
};

@ -5,8 +5,6 @@ BUGS:
* BUG: doesn't play you_died sound.
TODO:
* Rewrite dbc.hpp to actually work.
* Add a timer to the game engine so you can set a kind of pomodoro timer and if you don't meet the goal it costs you.
* Track the deaths.

Loading…
Cancel
Save