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

master
Zed A. Shaw 2 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; build_out = NULL;
game.event(GameEvent::BUILD_DONE);
state(BuildState::DONE); state(BuildState::DONE);
} else { } else {
auto m = parse_line(line); auto m = parse_line(line);
@ -171,6 +170,7 @@ void Builder::DONE(BuildEvent ev) {
gui.you_died(); gui.you_died();
} }
game.event(GameEvent::BUILD_DONE);
listener->reset_state(); listener->reset_state();
gui.output("^^^^^^^^^^^ END ^^^^^^^^^^^"); gui.output("^^^^^^^^^^^ END ^^^^^^^^^^^");
state(BuildState::WAITING); state(BuildState::WAITING);

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

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

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

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

@ -17,7 +17,7 @@ using namespace nlohmann;
using namespace ImGui; using namespace ImGui;
using std::string; 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"]; auto audio = data["audio"];
json::string_t file_name = audio[file_key].template get<string>(); 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.setBuffer(buffer);
sound.setLoop(loop);
} }
void SoundQuip::play() { void SoundQuip::play() {

@ -25,7 +25,7 @@ public:
SoundQuip() {}; 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 play();
void stop(); void stop();
}; };

@ -5,8 +5,6 @@ BUGS:
* BUG: doesn't play you_died sound. * BUG: doesn't play you_died sound.
TODO: 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. * 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. * Track the deaths.

Loading…
Cancel
Save