From 8d9ad3eb74bc0dfc647abf03b7b99ed16f2a9115 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 2 May 2016 21:24:02 -0500 Subject: implementing better modularity, came into bad bug. All creatures seem to have same near vector. --- inc/creature.hpp | 17 ++++++----------- inc/entity.hpp | 3 +++ inc/list.hpp | 3 ++- 3 files changed, 11 insertions(+), 12 deletions(-) (limited to 'inc') diff --git a/inc/creature.hpp b/inc/creature.hpp index ffff888..082e8d9 100644 --- a/inc/creature.hpp +++ b/inc/creature.hpp @@ -9,12 +9,11 @@ class Creature: public Entity { public: Creature(Window m, std::string s); - int Behavior(); - bool Action(); + void Behavior(); + void Action(); void Priority(); - void giveR(vector n){nR=n;}; - void giveC(vector n){nC=n;}; - + void giveN(vector n){N = n;}; + Location getLocation(){return L;}; double Distance(Location A, Location B){return sqrt(pow(A.x-B.x,2)+pow(A.y-B.y,2));}; int getHealth(){return health;}; @@ -22,9 +21,6 @@ class Creature: public Entity int getBestSense(){return bestSense;}; private: - int xTarget; - int yTarget; - bool hasTarget; bool wandering; @@ -34,10 +30,9 @@ class Creature: public Entity int speed = 1; bool able; int bestSense = 100; - - vector nR; //vector containing resources near the creature - vector nC; //vector containing creatures near the creature + vector N; + Entity *target; int n; }; diff --git a/inc/entity.hpp b/inc/entity.hpp index 0f35e86..540e7b9 100644 --- a/inc/entity.hpp +++ b/inc/entity.hpp @@ -9,7 +9,10 @@ class Entity public: void Place(); SDL_Texture* loadTexture(std::string path, Window main); + Location getLocation(){return L;}; int getType(){return type;}; + virtual void eat(void) {}; + virtual int getAmount(void) {}; protected: Location L; diff --git a/inc/list.hpp b/inc/list.hpp index 14a6a9a..9d05fec 100644 --- a/inc/list.hpp +++ b/inc/list.hpp @@ -12,7 +12,8 @@ class List List(Window m); void Behavior(); void Place(); - double Distance(Location A, Location B){return sqrt(pow(A.x-B.x,2)+pow(A.y-B.y,2));}; + double Distance(Location A, Location B){return sqrt(pow(A.x-B.x,2)+pow(A.y-B.y,2));}; + vector getNear(Creature C); private: //vectors containing objects of each type -- cgit v1.2.3