diff options
-rw-r--r-- | kurator/src/Battle.cpp | 9 | ||||
-rw-r--r-- | kurator/src/Battle.h | 1 | ||||
-rw-r--r-- | kurator/src/Session.cpp | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index b7893da..9ec2bdd 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -7,6 +7,7 @@ #include <utility> #include <raylib.h> +#include <imgui.h> #include <kurator/campaign/scenarios.h> #include <kurator/campaign/UniqueIdentifier.h> @@ -29,7 +30,8 @@ namespace kurator Battle::Battle(std::shared_ptr<Session> _session) : session {std::move(_session)}, - battle {sim::prepare(campaign::scenarios::example())} + battle {sim::prepare(campaign::scenarios::example())}, + time_factor {1.0} { battle->dispatcher().sink<sim::Hit>().connect<&Battle::on_hit>(*this); battle->dispatcher().sink<stats::ShipLeft>().connect<&Battle::on_ship_left>(*this); @@ -52,7 +54,7 @@ Battle::~Battle() void Battle::update(const float dt) { - battle->update(dt); + battle->update(dt * time_factor); auto& registry = battle->registry(); auto timers = registry.view<Timed>(); for (auto&& [entity, timer] : timers.each()) { @@ -70,6 +72,9 @@ Battle::update(const float dt) pop.speed.y -= damp.y; } balance.update(registry); + ImGui::Begin("Controls"); + ImGui::SliderFloat("Time Factor", &time_factor, 0.1f, 3.0f); + ImGui::End(); if (IsKeyPressed(KEY_SPACE)) session->set(std::make_shared<Log>(session, log)); } diff --git a/kurator/src/Battle.h b/kurator/src/Battle.h index 009f9c3..1ebfa35 100644 --- a/kurator/src/Battle.h +++ b/kurator/src/Battle.h @@ -30,6 +30,7 @@ private: std::unique_ptr<sim::Battle> battle; ForceBalance balance; EventLog log; + float time_factor; }; diff --git a/kurator/src/Session.cpp b/kurator/src/Session.cpp index 34f8214..4f8e8e2 100644 --- a/kurator/src/Session.cpp +++ b/kurator/src/Session.cpp @@ -25,9 +25,9 @@ Session::run() while (!window.should_close()) { if (!scene) return; + rlImGuiBegin(); scene->update(GetFrameTime()); BeginDrawing(); - rlImGuiBegin(); scene->draw(); rlImGuiEnd(); EndDrawing(); |