aboutsummaryrefslogtreecommitdiff
path: root/Simulation/SimBase_Update.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Simulation/SimBase_Update.cpp')
-rw-r--r--Simulation/SimBase_Update.cpp55
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();
+}