summaryrefslogtreecommitdiff
path: root/src/creature.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/creature.cpp')
-rw-r--r--src/creature.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/creature.cpp b/src/creature.cpp
index 207d3bd..d958d09 100644
--- a/src/creature.cpp
+++ b/src/creature.cpp
@@ -22,26 +22,36 @@ void Creature::Behavior()
void Creature::Action()
{
- //if(isclose)
- // eat//reproduce//etc;
+ //std::cout << (sqrt(((x-xT)^2)+((y-yT)^2));
+ if((sqrt(((x-xT)^2)+((y-yT)^2)))<2)
+ return; //eat//reproduce//etc;
if(x==xT)
- {
if(y<yT)
y++;
else
y--;
- }
else if(y==yT)
- {
if(x<xT)
x++;
else
x--;
- }
else
{
- srand(time(NULL));
- int z = rand()%1;
+ int z = rand()%2;
+ if(z)
+ {
+ if(x<xT)
+ x++;
+ else
+ x--;
+ }
+ else
+ {
+ if(y<xT)
+ y++;
+ else
+ y--;
+ }
}
}