diff options
author | tom <tom@ground-control> | 2016-05-02 21:24:02 -0500 |
---|---|---|
committer | tom <tom@ground-control> | 2016-05-02 21:24:02 -0500 |
commit | 8d9ad3eb74bc0dfc647abf03b7b99ed16f2a9115 (patch) | |
tree | eb16f853c280ed200953fbc7a500193a69ef8892 /inc | |
parent | 0346965968fb5da1a52ed8f896a922c63ce180f6 (diff) |
implementing better modularity, came into bad bug. All creatures seem to have same near vector.
Diffstat (limited to 'inc')
-rw-r--r-- | inc/creature.hpp | 17 | ||||
-rw-r--r-- | inc/entity.hpp | 3 | ||||
-rw-r--r-- | inc/list.hpp | 3 |
3 files changed, 11 insertions, 12 deletions
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<Resource*> n){nR=n;}; - void giveC(vector<Creature*> n){nC=n;}; - + void giveN(vector<Entity*> 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<Resource*> nR; //vector containing resources near the creature - vector<Creature*> nC; //vector containing creatures near the creature + vector<Entity*> 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<Entity*> getNear(Creature C); private: //vectors containing objects of each type |