]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/sim.cpp
camera controls
[blobs.git] / src / world / sim.cpp
index 0e0b46616694dfd9bf05fbf7089a3cb21b831024..8c3749f347bff8963783cb2f322c60f22da37683 100644 (file)
@@ -1,18 +1,47 @@
 #include "Simulation.hpp"
 
+#include "Body.hpp"
+#include "Planet.hpp"
+#include "Sun.hpp"
+
 
 namespace blobs {
 namespace world {
 
-Simulation::Simulation(Body &r)
-: root(r) {
+Simulation::Simulation(Body &r, app::Assets &assets)
+: root(r)
+, assets(assets)
+, bodies()
+, planets()
+, suns()
+, time(0.0) {
+       AddBody(r);
 }
 
 Simulation::~Simulation() {
 }
 
 
-void Simulation::Tick() {
+void Simulation::AddBody(Body &b) {
+       b.SetSimulation(*this);
+       bodies.insert(&b);
+}
+
+void Simulation::AddPlanet(Planet &p) {
+       AddBody(p);
+       planets.insert(&p);
+}
+
+void Simulation::AddSun(Sun &s) {
+       AddBody(s);
+       suns.insert(&s);
+}
+
+void Simulation::Tick(double dt) {
+       time += dt;
+       for (auto body : bodies) {
+               body->Tick(dt);
+       }
 }
 
 }