summaryrefslogtreecommitdiff
path: root/src/creature.cpp
diff options
context:
space:
mode:
authortom <tom@ground-control>2016-05-02 16:21:23 -0500
committertom <tom@ground-control>2016-05-02 16:21:23 -0500
commit084d556f831832c1ca15d1e7cd52944815d9beea (patch)
tree675973a47691c06f19bd27a742c4888c02d66863 /src/creature.cpp
parent42d7b3bb511333e242a74f360873deb64cd89522 (diff)
implemented the location fully into entity
Diffstat (limited to 'src/creature.cpp')
-rw-r--r--src/creature.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/creature.cpp b/src/creature.cpp
index 83b9f4d..01882a3 100644
--- a/src/creature.cpp
+++ b/src/creature.cpp
@@ -8,9 +8,10 @@ Creature::Creature(Window m, std::string s)
maxHealth = 1000;
hunger = 0;
- yPosition=yTarget=rand()%800;
- xPosition=xTarget=rand()%1200;
- hasTarget = false;
+ L.y=yTarget=rand()%800;
+ L.x=xTarget=rand()%1200;
+
+ hasTarget = false;
wandering = false;
able = true;
n=0;
@@ -108,49 +109,49 @@ bool Creature::Action()
}
//Makes moves towards target coordinates
- if(xPosition==xTarget)
+ if(L.x==xTarget)
{
- if(yPosition<yTarget)
- yPosition+=speed;
+ if(L.y<yTarget)
+ L.y+=speed;
else
- yPosition-=speed;
+ L.y-=speed;
}
- else if(yPosition==yTarget)
+ else if(L.y==yTarget)
{
- if(xPosition<xTarget)
- xPosition+=speed;
+ if(L.x<xTarget)
+ L.x+=speed;
else
- xPosition-=speed;
+ L.x-=speed;
}
- else if(xPosition<xTarget)
+ else if(L.x<xTarget)
{
- if(yPosition<yTarget)
+ if(L.y<yTarget)
{
- xPosition+=speed;
- yPosition+=speed;
+ L.x+=speed;
+ L.y+=speed;
}
else
{
- xPosition+=speed;
- yPosition-=speed;
+ L.x+=speed;
+ L.y-=speed;
}
}
- else if (xPosition>xTarget)
+ else if (L.x>xTarget)
{
- if(yPosition<yTarget)
+ if(L.y<yTarget)
{
- xPosition-=speed;
- yPosition+=speed;
+ L.x-=speed;
+ L.y+=speed;
}
else
{
- xPosition-=speed;
- yPosition-=speed;
+ L.x-=speed;
+ L.y-=speed;
}
}
@@ -160,7 +161,7 @@ bool Creature::Action()
Location Creature::getLocation()
{
//returns location object of the specific creature
- Location L(xPosition, yPosition, 1);
+ //Location L(xPosition, yPosition, 1);
return L;
}