diff options
author | Aki <please@ignore.pl> | 2022-12-21 01:27:55 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-12-21 01:27:55 +0100 |
commit | b6fd1823082cfa84993a70ba80243d3aa2f089f1 (patch) | |
tree | 6ea074e285f741fc70109ed9dd31a59fbab5bade | |
parent | 34493a02b1cd2e7ec2e96192ce88ee00367dd366 (diff) | |
download | kurator-b6fd1823082cfa84993a70ba80243d3aa2f089f1.zip kurator-b6fd1823082cfa84993a70ba80243d3aa2f089f1.tar.gz kurator-b6fd1823082cfa84993a70ba80243d3aa2f089f1.tar.bz2 |
Added simple window to change simulation time factor
-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(); |