summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortom <tom@ground-control>2016-05-02 22:41:40 -0500
committertom <tom@ground-control>2016-05-02 22:41:40 -0500
commit05c98dad6bca7f0bcae2a09a12f4863dac546e22 (patch)
tree2e1eb682ac2136a97a39dfa1637cd91d66112bdc
parent6873831fa5c99f74609c60e2918692cdd46f1aa1 (diff)
puuuuurfct
-rw-r--r--inc/window.hpp1
-rw-r--r--src/creature.cpp10
-rw-r--r--src/main.cpp1
3 files changed, 9 insertions, 3 deletions
diff --git a/inc/window.hpp b/inc/window.hpp
index 97e6c09..49bdb09 100644
--- a/inc/window.hpp
+++ b/inc/window.hpp
@@ -13,6 +13,7 @@
#include <chrono>
#include <random>
#include <list>
+#include <algorithm>
using namespace std;
diff --git a/src/creature.cpp b/src/creature.cpp
index 3b26f63..cc7fb3e 100644
--- a/src/creature.cpp
+++ b/src/creature.cpp
@@ -27,7 +27,7 @@ void Creature::Behavior()
}
void Creature::Priority()
-{
+{
for(list <Entity*>::iterator it = N.begin(); it!=N.end(); it++){
if((*it)->getType() == 2){
if(!hasTarget){
@@ -62,8 +62,12 @@ void Creature::Action()
hasTarget = false;
}
}
- else
- Move(wTarget);
+ else{
+ if(Distance(L,wTarget)<5)
+ wander = false;
+ else
+ Move(wTarget);
+ }
}
void Creature::Move(Location l)
diff --git a/src/main.cpp b/src/main.cpp
index 25d4cc4..48d3c64 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2,6 +2,7 @@
int main()
{
+ srand(time(NULL));
Window main;
List L(main);
Event e;