aboutsummaryrefslogtreecommitdiff
path: root/CollisionContext.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-22 19:55:53 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-22 19:55:53 +0200
commit3e1b0eb968d90f1ba5163b220c4e39dd7fd1e51b (patch)
tree2f9dcb8b7ac085514913a1ad114a5275978f95fd /CollisionContext.cpp
parent99d7d1695fec28208e19b34bc754dff5dd1e5642 (diff)
finish collision checking implementation
Diffstat (limited to 'CollisionContext.cpp')
-rw-r--r--CollisionContext.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/CollisionContext.cpp b/CollisionContext.cpp
index ec608b5..6df5d3b 100644
--- a/CollisionContext.cpp
+++ b/CollisionContext.cpp
@@ -2,7 +2,9 @@
#include "CollisionContext.h"
#include "Museum.h"
+
#include "NaiveCollisionChecker.h"
+#include "NullCollisionChecker.h"
#include "QuadTreeCollisionChecker.h"
using namespace std;
@@ -13,9 +15,25 @@ shared_ptr<CollisionChecker> CollisionContext::get_checker() {
return this->checker;
}
+shared_ptr<CollisionChecker> CollisionContext::create_checker() {
+ switch(this->checker_index) {
+ case 0: return make_shared<NullCollisionChecker>(this->museum);
+ case 1: return make_shared<QuadTreeCollisionChecker>(this->museum);
+ case 2: return make_shared<NaiveCollisionChecker>(this->museum);
+ }
+
+ this->checker_index = 0;
+ return this->create_checker();
+}
+
void CollisionContext::update() {
- this->checker = std::make_shared<QuadTreeCollisionChecker>(this->museum);
- // this->checker = std::make_shared<NaiveCollisionChecker>(this->museum);
+ for (Artist * artist : this->museum.people.get_artists())
+ artist->colliding = false;
+ this->checker = this->create_checker();
this->checker->check();
}
+void CollisionContext::cycle_method() {
+ this->checker_index++;
+}
+