summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortom <tombarrett@siu.edu>2017-02-12 07:57:21 -0600
committertom <tombarrett@siu.edu>2017-02-12 07:57:21 -0600
commit1da46794f74ebd8f445fcd70cbe0420eadb648e4 (patch)
treefee655a50188e50b7c63d6b855bc671e0a1b0128 /src
parent358ea01c03d787377ef88945706f350befd5b7a9 (diff)
-removed grouping
Diffstat (limited to 'src')
-rw-r--r--src/creature.cpp9
-rw-r--r--src/list.cpp6
2 files changed, 9 insertions, 6 deletions
diff --git a/src/creature.cpp b/src/creature.cpp
index 7a86af9..0b7a438 100644
--- a/src/creature.cpp
+++ b/src/creature.cpp
@@ -14,8 +14,11 @@ Creature::Creature(Window M, SDL_Rect R, Dna D)
type = CREATURE_TYPE;
health = mine.maxHealth/2;
gender = rand() % 2;
+ age = 0;
+ pregnancyTime = 0;
able = true;
pregnancyReady = false;
+ pregnate = false;
}
void Creature::Behavior()
@@ -56,7 +59,8 @@ void Creature::Priority()
void Creature::setTarget()
{
- for(std::list <Entity*>::iterator it = N.begin(); it!=N.end(); it++){
+ std::random_shuffle(N.begin(),N.end());
+ for(std::vector <Entity*>::iterator it = N.begin(); it!=N.end(); it++){
if( (*it)->getType() == RESOURCE_TYPE && hungry){
target = *it;
hasTarget = true;
@@ -80,12 +84,11 @@ void Creature::setTarget()
void Creature::checkTarget()
{
- for(std::list <Entity*>::iterator it = N.begin(); it!=N.end(); it++)
+ for(std::vector <Entity*>::iterator it = N.begin(); it!=N.end(); it++)
if( target == *it )
return;
hasTarget = false;
- return;
}
diff --git a/src/list.cpp b/src/list.cpp
index edf3063..0439278 100644
--- a/src/list.cpp
+++ b/src/list.cpp
@@ -38,7 +38,7 @@ void List::Remove()
void List::Behavior()
{
for(std::list<Creature>::iterator it = C.begin(); it!=C.end(); it++){
- std::list<Entity*> N = getNear(*it);
+ std::vector<Entity*> N = getNear(*it);
it->giveN(N);
it->Behavior();
@@ -71,9 +71,9 @@ void List::Place()
it->Place();
}
-std::list<Entity*> List::getNear(Creature nC)
+std::vector<Entity*> List::getNear(Creature nC)
{
- std::list<Entity*> N;
+ std::vector<Entity*> N;
for(std::list<Resource>::iterator it = R.begin(); it!=R.end(); it++)
if( nC.getBestSense() > Distance(nC.getRect(),it->getRect()) )