diff options
author | majortom6 <tombarrett@siu.edu> | 2017-02-26 07:55:18 -0600 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-03-07 13:23:42 -0600 |
commit | e54170cfb8c0fb99ecdc3b1e57e832dec58ee76e (patch) | |
tree | 7cfc2c1949c22554559f58d0734f355b260fd184 | |
parent | 2e4d19ba21347cc370d1aae7a57298328b94ca4e (diff) |
-reimplemented a creature only being aware of something within its best sense, this also fixed the weird all creatures having the same target bug
-rw-r--r-- | inc/constants.hpp | 4 | ||||
-rw-r--r-- | src/list.cpp | 16 |
2 files changed, 11 insertions, 9 deletions
diff --git a/inc/constants.hpp b/inc/constants.hpp index 6cb2982..dc0ddec 100644 --- a/inc/constants.hpp +++ b/inc/constants.hpp @@ -39,8 +39,8 @@ const float CREATURE_SIDES = 4.0; const float RESOURCE_SIDES = 10; // Quadtree -const int MAX_OBJECTS = 10; -const int MAX_LEVELS = 10; +const int MAX_OBJECTS = 5; +const int MAX_LEVELS = 20; // Camera const float MOVE_AMOUNT = .2; diff --git a/src/list.cpp b/src/list.cpp index ca69a4d..30b0eb1 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -41,9 +41,7 @@ void List::Behavior() it->Behavior(); if(it->getPregnancyReady()){ - DNA d = it->getChildsDNA(); - Rectangle tmp = it->getRectangle(); - Creature X(tmp,d); + Creature X(it->getRectangle(),it->getChildsDNA()); creatures.push_back(X); it->hadPregnancy(); } @@ -74,12 +72,16 @@ void List::Place() } } -std::vector<Entity*> List::getNear(Creature nC) +std::vector<Entity*> List::getNear(Creature c) { - std::vector<Entity*> N; - N = tree.retrieve(N, nC.getGFXD()); + std::vector<Entity*> near; + near = tree.retrieve(near, c.getGFXD()); - return N; + for(std::vector<Entity*>::iterator it = near.begin(); it!= near.end(); it++) + if(c.getBestSense() < Distance(c.getRectangle(),(*it)->getRectangle())) + near.erase(it--); + + return near; } std::vector<GraphicsData> List::drawQuadTree(){ |