summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorTom <spalf0@gmail.com>2015-05-26 14:04:04 -0500
committerTom <spalf0@gmail.com>2015-05-26 14:04:04 -0500
commit6b967f3bd7a3e7203b57bd9e4edb0db82bc9ed1c (patch)
tree8dfb8ce54fb9ef775bd2153aae67307d1f943e78 /inc
parentce6b35d717de85a7ac45fa98197edf13e1820c8a (diff)
revamped the list and creatures
two bugs i can see right now -somehow when a resource has less than 0 amount it still sticks around (somewhat rare) -some creatures just bounce back and forth until they die not getting to their target
Diffstat (limited to 'inc')
-rw-r--r--inc/creature.hpp9
-rw-r--r--inc/list.hpp1
-rw-r--r--inc/resource.hpp2
-rw-r--r--inc/window.hpp2
4 files changed, 10 insertions, 4 deletions
diff --git a/inc/creature.hpp b/inc/creature.hpp
index 7c5c8cb..24cad37 100644
--- a/inc/creature.hpp
+++ b/inc/creature.hpp
@@ -2,6 +2,7 @@
#define creature_h
#include "entity.hpp"
+#include "resource.hpp"
#include "location.hpp"
class Creature: public Entity
@@ -12,15 +13,19 @@ class Creature: public Entity
bool Action();
void Priority();
Location getLocation();
- void giveKnown(std::vector<Location> Z){location = Z;};
+ void give(vector<Resource*> n){nR=n;};
int getHealth(){return health;};
+ double Distance(Location A, Location B);
private:
int xTarget; //x-coordinate of creature's target position
int yTarget; //y-coordinate of creature's target position
+ bool hasTarget;
int health; //health of a creature (0-100)
int hunger; //value associated with a creatures want to find food (0-100)
- std::vector<Location> location; //vector containing objects near the creature
+ int speed = 1;
+ vector<Resource*> nR; //vector containing objects near the creature
+ int n; // counter for which place in resource array is targeted
};
#endif
diff --git a/inc/list.hpp b/inc/list.hpp
index f370d24..934c319 100644
--- a/inc/list.hpp
+++ b/inc/list.hpp
@@ -19,7 +19,6 @@ class List
Window main = Window("no");//will be needed for adding R's and C's after constructor.
std::vector<Resource> R;
std::vector<Creature> C;
- std::vector<Location> L;
};
#endif
diff --git a/inc/resource.hpp b/inc/resource.hpp
index a1dd988..c551844 100644
--- a/inc/resource.hpp
+++ b/inc/resource.hpp
@@ -10,7 +10,7 @@ class Resource: public Entity
Resource(Window m, std::string s);
Resource(Window m, std::string s, Location z);
Location getLocation();
- void eat(){amount-=10;};
+ void eat();
int getAmount(){return amount;};
private:
diff --git a/inc/window.hpp b/inc/window.hpp
index 073a106..1ea2733 100644
--- a/inc/window.hpp
+++ b/inc/window.hpp
@@ -13,6 +13,8 @@
#include <chrono>
#include <random>
+using namespace std;
+
class Window
{
public: