From 95fb44dd7009ddbb157fa4c54ddbab88a0af0c0b Mon Sep 17 00:00:00 2001 From: tom Date: Fri, 8 May 2015 16:24:37 -0500 Subject: they may eat if they can reach food in time --- src/creature.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/creature.cpp b/src/creature.cpp index dcc8337..7f31003 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -14,9 +14,13 @@ Creature::Creature(Window m, std::string s) //Constructor void Creature::Behavior() { - health-=5; //Decrements health each time a behavior is executed + health-=1; //Decrements health each time a behavior is executed this->Priority(); //Checks which action has priority (doesn't really do this right now) - this->Action(); //Does action + + if(this->Action()) + { + health+=10; + } } void Creature::Priority() @@ -33,11 +37,11 @@ void Creature::Priority() } } -void Creature::Action() +bool Creature::Action() { //If the distance is close, will return an bool if(sqrt(pow(xPosition - xTarget, 2) + pow(yPosition - yTarget, 2)) < 2) - return; //<--- eat action should be here + return true; //Makes moves towards target coordinates if(xPosition==xTarget) @@ -85,6 +89,7 @@ void Creature::Action() yPosition--; } } + return false; } Location Creature::getLocation() -- cgit v1.2.3