summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/constants.hpp4
-rw-r--r--src/list.cpp16
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(){