From 4619a1d86dc21c42439b2c2efd6654b565d46441 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 10 Nov 2022 23:40:23 +0100 Subject: Testing out simple updating system --- battles/src/Battle.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'battles/src/Battle.cpp') 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(entity, ship.type); @@ -26,5 +26,14 @@ Battle::Battle(Scenario scenario) } +void +Battle::update(const float dt) +{ + auto view = registry.view(); + for (auto&& [entity, transform, team] : view.each()) + transform.position.x += 0.1 * dt * (team.id * 2 - 1); +} + + } // namespace battles } // namespace kurator -- cgit v1.1