aboutsummaryrefslogtreecommitdiff
path: root/Museum.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Museum.cpp')
-rw-r--r--Museum.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Museum.cpp b/Museum.cpp
index 7c2a722..6962e20 100644
--- a/Museum.cpp
+++ b/Museum.cpp
@@ -1,5 +1,32 @@
#include "Museum.h"
+using namespace std;
+
+Museum::Museum() {
+ this->worker = new std::thread(&Museum::work, this);
+}
+
+Museum::~Museum() {
+ this->working = false;
+ this->worker->join();
+ if (this->worker != nullptr) {
+ delete this->worker;
+ this->worker = nullptr;
+ }
+}
+
void Museum::update() {
+ this->people.update();
+ // this->canvas.update();
+}
+
+void Museum::work() {
+ while (this->working) {
+ if (this->paused) continue; // wait if paused
+
+ auto next = chrono::steady_clock::now() + this->tick_interval;
+ this->update();
+ this_thread::sleep_until(next);
+ }
}