From 0346965968fb5da1a52ed8f896a922c63ce180f6 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 2 May 2016 18:23:19 -0500 Subject: done refractoring type --- inc/entity.hpp | 1 + inc/location.hpp | 7 +++---- src/creature.cpp | 12 +++++------- src/resource.cpp | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/inc/entity.hpp b/inc/entity.hpp index ee42858..0f35e86 100644 --- a/inc/entity.hpp +++ b/inc/entity.hpp @@ -9,6 +9,7 @@ class Entity public: void Place(); SDL_Texture* loadTexture(std::string path, Window main); + int getType(){return type;}; protected: Location L; diff --git a/inc/location.hpp b/inc/location.hpp index 0e3ee23..5392e9b 100644 --- a/inc/location.hpp +++ b/inc/location.hpp @@ -4,11 +4,10 @@ class Location { public: - Location(int x1, int y1, int t1){x=x1;y=y1;type=t1;}; - Location(){x=y=type=0;}; + Location(int x1, int y1){x=x1;y=y1;}; + Location(){x=y=0;}; int x; - int y; - int type; //value associated with type of entity at location. 1: Creature, 2: Resource + int y; }; #endif diff --git a/src/creature.cpp b/src/creature.cpp index 9404ba2..f2b85e5 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -10,7 +10,8 @@ Creature::Creature(Window m, std::string s) L.y=yTarget=rand()%800; L.x=xTarget=rand()%1200; - + type = 1; + hasTarget = false; wandering = false; able = true; @@ -23,16 +24,13 @@ int Creature::Behavior() this->Priority(); - if(this->Action()) - { - if(nR.size()) - { + if(this->Action()){ + if(nR.size()){ nR[n]->eat(); if(healthgetLocation(),L)<5) wandering = false; hasTarget = false; diff --git a/src/resource.cpp b/src/resource.cpp index 8b00e0a..08929bc 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -7,7 +7,7 @@ Resource::Resource(Window m, std::string s) L.y = rand()%800; L.x = rand()%1200; - L.type = 2; + type = 2; amount = 100; } @@ -19,7 +19,7 @@ Resource::Resource(Window m, std::string s, Location z) L.y = z.y; L.x = z.x; - L.type = 2; + type = 2; amount = 100; } -- cgit v1.2.3