diff options
author | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 19:27:35 +0100 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 19:27:49 +0100 |
commit | 17909d029c6a8872b2fddf4e171d7925bbbe9c5c (patch) | |
tree | cbb08af84cd68d24acc362d593a2048b0fa79689 /Simulation/SimBase_Update.cpp |
Diffstat (limited to 'Simulation/SimBase_Update.cpp')
-rw-r--r-- | Simulation/SimBase_Update.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
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(); +} |