From 17909d029c6a8872b2fddf4e171d7925bbbe9c5c Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:27:35 +0100 Subject: Initial commit --- Simulation/SimBase_Update.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Simulation/SimBase_Update.cpp (limited to 'Simulation/SimBase_Update.cpp') diff --git a/Simulation/SimBase_Update.cpp b/Simulation/SimBase_Update.cpp new file mode 100644 index 0000000..fc50c58 --- /dev/null +++ b/Simulation/SimBase_Update.cpp @@ -0,0 +1,55 @@ +#include "SimBase.hpp" + +void SimBase::update() +{ + if (paused) + { + camera.update(); + return; + } + + ++step; + text.steps.setString("Steps: " + nts(step)); + + if (timer.getElapsedTime().asSeconds() > 1.f) + { + timer.restart(); + text.fps.setString("FPS: " + nts(frameCounter)); + frameCounter = 0; + } + else + { + ++frameCounter; + } + + for (auto &i : zappers) + { + i.update(); + } + + // Create new pellet if needed + if (pelletCount < prms.pelletQtty && !(step % prms.pelletCreationDelay)) + { + for (auto &i : pellets) + { + if (!i.isCreated()) + { + i.create(); + break; + } + } + } + for (auto &i : pellets) + { + i.update(); + } + + for (auto &i : corpses) + { + i.update(); + } + + updateSpecs(); + + tank.updateAllPhysics(); +} -- cgit v1.2.1