From ce6b35d717de85a7ac45fa98197edf13e1820c8a Mon Sep 17 00:00:00 2001 From: tom Date: Fri, 8 May 2015 17:41:48 -0500 Subject: added removal of resources once eaten, from the L and R vector creatures that done move don't die right now, we need them to wander if they dont have a priority **difficult** --- src/creature.cpp | 8 +++++++- src/list.cpp | 36 +++++++++++++++++++++++++++++++++--- src/resource.cpp | 4 ++++ 3 files changed, 44 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/creature.cpp b/src/creature.cpp index 7f31003..c7b36ca 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -12,7 +12,7 @@ Creature::Creature(Window m, std::string s) //Constructor xPosition=xTarget=rand()%1200; } -void Creature::Behavior() +int Creature::Behavior() { health-=1; //Decrements health each time a behavior is executed this->Priority(); //Checks which action has priority (doesn't really do this right now) @@ -20,7 +20,9 @@ void Creature::Behavior() if(this->Action()) { health+=10; + return 2; } + return 0; } void Creature::Priority() @@ -40,6 +42,10 @@ void Creature::Priority() bool Creature::Action() { //If the distance is close, will return an bool + + //if(xPosition == xTarget && yPosition == yTarget) + // return false; + if(sqrt(pow(xPosition - xTarget, 2) + pow(yPosition - yTarget, 2)) < 2) return true; diff --git a/src/list.cpp b/src/list.cpp index 6317d45..cd69f8f 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -46,12 +46,42 @@ void List::Place() void List::Behavior() { - int i, j; + int i, j, k, l; std::vector Z; for(i = 0; i < C.size(); i++) { - C[i].Behavior(); //executes the behavior of the creature at i + int o = C[i].Behavior(); + + if(o==1) + { + //If next to creature + } + + if(o==2) + { + //If next to resource + Location tmp = C[i].getLocation(); + for(k=0;k