diff options
Diffstat (limited to 'CollisionContext.cpp')
-rw-r--r-- | CollisionContext.cpp | 22 |
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++; +} + |