Quick ability to set the countdown timer length.

master
Zed A. Shaw 2 days ago
parent d4d8c780a4
commit 8a30fafabb
  1. 1
      game_engine.hpp
  2. 6
      gui.cpp
  3. 3
      gui.hpp
  4. 17
      main.cpp

@ -24,7 +24,6 @@ enum class GameBonus {
}; };
class GameEngine : DeadSimpleFSM<GameState, GameEvent> { class GameEngine : DeadSimpleFSM<GameState, GameEvent> {
std::map<string, int> damage_types{ std::map<string, int> damage_types{
{"error", 4}, {"error", 4},
{"warning", 1}, {"warning", 1},

@ -16,7 +16,9 @@
using std::string, std::vector; using std::string, std::vector;
GUI::GUI(SFMLBackend &backend) : sfml(backend) { GUI::GUI(SFMLBackend &backend, int timer_seconds) :
sfml(backend), $timer_seconds(timer_seconds)
{
using namespace guecs; using namespace guecs;
$gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); $gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
@ -44,7 +46,7 @@ GUI::GUI(SFMLBackend &backend) : sfml(backend) {
auto log = $gui.entity("log"); auto log = $gui.entity("log");
auto& rect = $gui.get<Rectangle>(log); auto& rect = $gui.get<Rectangle>(log);
rect.color = {255,255,255,255}; rect.color = {255,255,255,255};
$gui.set<Effect>(log, {1000.0, "build_status"}); $gui.set<Effect>(log, {(float)$timer_seconds, "build_status"});
auto clock = $gui.entity("clock"); auto clock = $gui.entity("clock");
$gui.set<Label>(clock, {L"00:00:00", 110}); $gui.set<Label>(clock, {L"00:00:00", 110});

@ -16,10 +16,11 @@ class GUI {
std::wstring $status; std::wstring $status;
DinkyECS::Entity $hp_bar; DinkyECS::Entity $hp_bar;
bool $hit_error = false; bool $hit_error = false;
int $timer_seconds;
public: public:
GUI(SFMLBackend &backend); GUI(SFMLBackend &backend, int timer_seconds);
void output(const string msg); void output(const string msg);
void update_status(GameEngine &game, size_t line_length, bool is_error); void update_status(GameEngine &game, size_t line_length, bool is_error);

@ -4,16 +4,29 @@
#include "sound.hpp" #include "sound.hpp"
#include "textures.hpp" #include "textures.hpp"
#include "shaders.hpp" #include "shaders.hpp"
#include <unistd.h>
int main() int main(int argc, char *argv[])
{ {
int opt = 0;
int timer_seconds = 60 * 60;
while((opt = getopt(argc, argv, "-t:")) != -1) {
switch(opt) {
case 't':
timer_seconds = atoi(optarg) * 60;
fmt::println("Setting count down timer to {} seconds.", timer_seconds);
break;
}
}
sound::init(); sound::init();
shaders::init(); shaders::init();
textures::init(); textures::init();
GameEngine game{100}; GameEngine game{100};
auto backend = SFMLBackend(game); auto backend = SFMLBackend(game);
GUI gui(backend); GUI gui(backend, timer_seconds);
auto builder = Builder(gui, game); auto builder = Builder(gui, game);
backend.startup(); backend.startup();

Loading…
Cancel
Save