summaryrefslogtreecommitdiff
path: root/src/list.cpp
diff options
context:
space:
mode:
authormajortom6 <tombarrett@siu.edu>2017-02-26 07:55:18 -0600
committerTom Barrett <tombarrett@siu.edu>2017-03-07 13:23:42 -0600
commite54170cfb8c0fb99ecdc3b1e57e832dec58ee76e (patch)
tree7cfc2c1949c22554559f58d0734f355b260fd184 /src/list.cpp
parent2e4d19ba21347cc370d1aae7a57298328b94ca4e (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
Diffstat (limited to 'src/list.cpp')
-rw-r--r--src/list.cpp16
1 files changed, 9 insertions, 7 deletions
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(){