summaryrefslogtreecommitdiff
path: root/src/creature.cpp
diff options
context:
space:
mode:
authortom <tom@ground-control>2015-05-05 21:01:52 -0500
committertom <tom@ground-control>2015-05-05 21:01:52 -0500
commitaaf0a73578ecbb8212e0d224d6fff68a229b1f48 (patch)
tree46f6d91c1bc02e434812af59477e11fb5e521713 /src/creature.cpp
parent22cd24a1fe33b6bc9f52a600feb5cdb8d868d50f (diff)
fleshed out list, locations of all creatures and resources are now within
Diffstat (limited to 'src/creature.cpp')
-rw-r--r--src/creature.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/creature.cpp b/src/creature.cpp
index 8e86c0d..cc3fa08 100644
--- a/src/creature.cpp
+++ b/src/creature.cpp
@@ -4,23 +4,25 @@ Creature::Creature(Window m, std::string s)
{
texture = loadTexture(s, m);
renderer = m.getRenderer();
+ hp = 100;
+ hu = 0;
- srand(time(NULL));
- int z = rand()%800;
- y=z;
-
- z = rand()%800;
- x=z;
- std::cout << x << ' ' << y << std::endl;
-
+ int zy = rand()%800;
+ int zx = rand()%1200;
+ y=zy;
+ x=zx;
+ //std::cout << x << ' ' << y << std::endl;
+
//For the test resource
xT=yT=300;
}
void Creature::Behavior()
{
+ hp--;
//Detection
+
//Priorities
//Action
@@ -34,15 +36,19 @@ void Creature::Action()
return; //eat//reproduce//etc;
if(x==xT)
+ {
if(y<yT)
y++;
else
y--;
+ }
else if(y==yT)
+ {
if(x<xT)
x++;
else
x--;
+ }
else
{
int z = rand()%2;
@@ -55,10 +61,16 @@ void Creature::Action()
}
else
{
- if(y<xT)
+ if(y<yT)
y++;
else
y--;
}
}
}
+
+Location Creature::getLocation()
+{
+ Location L(x,y,1);
+ return L;
+}