From 3e1b0eb968d90f1ba5163b220c4e39dd7fd1e51b Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 22 Oct 2024 19:55:53 +0200 Subject: finish collision checking implementation --- CollisionContext.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'CollisionContext.cpp') 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 CollisionContext::get_checker() { return this->checker; } +shared_ptr CollisionContext::create_checker() { + switch(this->checker_index) { + case 0: return make_shared(this->museum); + case 1: return make_shared(this->museum); + case 2: return make_shared(this->museum); + } + + this->checker_index = 0; + return this->create_checker(); +} + void CollisionContext::update() { - this->checker = std::make_shared(this->museum); - // this->checker = std::make_shared(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++; +} + -- cgit v1.2.3