summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/creature.cpp13
-rw-r--r--src/list.cpp3
-rw-r--r--src/resource.cpp2
3 files changed, 6 insertions, 12 deletions
diff --git a/src/creature.cpp b/src/creature.cpp
index ef3d6c1..5c3bb8e 100644
--- a/src/creature.cpp
+++ b/src/creature.cpp
@@ -8,16 +8,13 @@ Creature::Creature(Window m, std::string s) //Constructor
hunger = 0;
//initializes random start coordinates for creature, target position is equivalent to it's position
- int yStart = rand()%800;
- int xStart = rand()%1200;
- yPosition=yTarget=yStart;
- xPosition=xTarget=xStart;
+ yPosition=yTarget=rand()%800;
+ xPosition=xTarget=rand()%1200;
}
void Creature::Behavior()
{
health--; //Decrements health each time a behavior is executed
- //Detection
this->Priority(); //Checks which action has priority (doesn't really do this right now)
this->Action(); //Does action
}
@@ -28,19 +25,17 @@ void Creature::Priority()
int i;
for(i=0;i<location.size();i++)
{
- std::cout << location[i].type;
if(location[i].type==2)
{
xTarget = location[i].x;
yTarget = location[i].y;
- std::cout << xTarget << "IN\n";
}
}
}
void Creature::Action()
{
- //If the distance is too small, do something?
+ //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
@@ -94,7 +89,7 @@ void Creature::Action()
Location Creature::getLocation()
{
- //returns location vector of creatures position coordinates
+ //returns location object of the specific creature
Location L(xPosition, yPosition, 1);
return L;
}
diff --git a/src/list.cpp b/src/list.cpp
index b86f077..2140a75 100644
--- a/src/list.cpp
+++ b/src/list.cpp
@@ -65,6 +65,5 @@ void List::Behavior()
double List::Distance(Location A, Location B)
{
//computes distance between two points
- double z = sqrt(pow(A.x - B.x, 2) + pow(A.y - B.y, 2));
- return z;
+ return sqrt(pow(A.x - B.x, 2) + pow(A.y - B.y, 2));
}
diff --git a/src/resource.cpp b/src/resource.cpp
index c4a9341..5044760 100644
--- a/src/resource.cpp
+++ b/src/resource.cpp
@@ -12,7 +12,7 @@ Resource::Resource(Window m, std::string s) //Constructor
xPosition = xStart;
}
-Location Resource::getLocation() //Returns resource location vector
+Location Resource::getLocation() //Returns resource object
{
Location L(xPosition,yPosition,2);
return L;