summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-11-10 23:40:23 +0100
committerAki <please@ignore.pl>2022-11-10 23:40:23 +0100
commit4619a1d86dc21c42439b2c2efd6654b565d46441 (patch)
tree298c88de646cad69a9922968fd436a9397959969
parent35a39b4172008546f0bb4640114a42fb3f3a6f77 (diff)
downloadkurator-4619a1d86dc21c42439b2c2efd6654b565d46441.zip
kurator-4619a1d86dc21c42439b2c2efd6654b565d46441.tar.gz
kurator-4619a1d86dc21c42439b2c2efd6654b565d46441.tar.bz2
Testing out simple updating system
-rw-r--r--battles/include/kurator/battles/Battle.h1
-rw-r--r--battles/src/Battle.cpp11
-rw-r--r--kurator/src/Battle.cpp3
3 files changed, 13 insertions, 2 deletions
diff --git a/battles/include/kurator/battles/Battle.h b/battles/include/kurator/battles/Battle.h
index 0923f36..468a972 100644
--- a/battles/include/kurator/battles/Battle.h
+++ b/battles/include/kurator/battles/Battle.h
@@ -14,6 +14,7 @@ namespace battles
struct Battle
{
explicit Battle(Scenario scenario);
+ void update(float dt);
entt::registry registry;
};
diff --git a/battles/src/Battle.cpp b/battles/src/Battle.cpp
index e410f07..454cbfd 100644
--- a/battles/src/Battle.cpp
+++ b/battles/src/Battle.cpp
@@ -16,7 +16,7 @@ namespace battles
Battle::Battle(Scenario scenario)
{
std::random_device dev;
- std::uniform_real_distribution<> pos{-5.0, 5.0};
+ std::uniform_real_distribution<> pos{-2.5, 2.5};
for (const auto& ship : scenario.ships) {
const auto entity = registry.create();
registry.emplace<universe::ShipType>(entity, ship.type);
@@ -26,5 +26,14 @@ Battle::Battle(Scenario scenario)
}
+void
+Battle::update(const float dt)
+{
+ auto view = registry.view<Transform, Team>();
+ for (auto&& [entity, transform, team] : view.each())
+ transform.position.x += 0.1 * dt * (team.id * 2 - 1);
+}
+
+
} // namespace battles
} // namespace kurator
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp
index 7d924b5..5aa18fe 100644
--- a/kurator/src/Battle.cpp
+++ b/kurator/src/Battle.cpp
@@ -28,8 +28,9 @@ Battle::Battle(std::shared_ptr<Session> _session) :
void
-Battle::update(const float)
+Battle::update(const float dt)
{
+ battle.update(dt);
if (IsKeyPressed(KEY_SPACE))
session->set(std::make_shared<Title>(session));
}