From f2f0867edd0d9624a77e4e5db39825b8ea1a55d0 Mon Sep 17 00:00:00 2001 From: tom Date: Sat, 14 Jan 2017 11:56:33 -0600 Subject: completly remove location structure and replaced it with sdl_rect --- inc/creature.hpp | 17 ++++++++--------- inc/entity.hpp | 5 ----- inc/list.hpp | 7 +++---- inc/location.hpp | 13 ------------- inc/main.hpp | 1 - inc/resource.hpp | 5 +---- 6 files changed, 12 insertions(+), 36 deletions(-) delete mode 100644 inc/location.hpp (limited to 'inc') diff --git a/inc/creature.hpp b/inc/creature.hpp index 8515bc0..f51d083 100644 --- a/inc/creature.hpp +++ b/inc/creature.hpp @@ -4,23 +4,21 @@ #include #include -#include "location.hpp" #include "entity.hpp" #include "constants.hpp" class Creature: public Entity { public: - Creature(Window m, int size); + Creature(Window m, SDL_Rect R); void Behavior(); void Action(); void Priority(); void setTarget(); - void Move(Location l); + void Move(SDL_Rect R); void giveN(list 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));}; + double Distance(SDL_Rect A, SDL_Rect B){return sqrt(pow(A.x-B.x,2)+pow(A.y-B.y,2));}; int getHealth(){return health;}; bool doesItHaveTarget(){return hasTarget;}; int getBestSense(){return bestSense;}; @@ -28,14 +26,15 @@ class Creature: public Entity private: bool hasTarget; bool wander; - Location wTarget; + SDL_Rect wTarget; + int health; - int reach = CREATURE_REACH; + int reach; int maxHealth; bool hungry; - int speed = CREATURE_SPEED; + int speed; bool able; - int bestSense = CREATURE_BEST_SENSE; + int bestSense; list N; Entity *target; diff --git a/inc/entity.hpp b/inc/entity.hpp index d02f689..5941a9c 100644 --- a/inc/entity.hpp +++ b/inc/entity.hpp @@ -2,17 +2,13 @@ #define entity_h #include "window.hpp" -#include "location.hpp" class Entity { public: - void Init(Window m); - void Init(Window m, Location z); void Place(); int getType(){return type;}; - Location getLocation(){return L;}; SDL_Rect getRect(){return rect;}; virtual void eat(void){}; @@ -21,7 +17,6 @@ class Entity protected: int type; SDL_Rect rect; - Location L; SDL_Renderer* renderer; }; diff --git a/inc/list.hpp b/inc/list.hpp index 8cf409b..6800b34 100644 --- a/inc/list.hpp +++ b/inc/list.hpp @@ -1,12 +1,12 @@ #ifndef list_h #define list_h +#include #include #include "creature.hpp" #include "resource.hpp" #include "window.hpp" -#include "location.hpp" #include "constants.hpp" class List @@ -15,12 +15,11 @@ 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(SDL_Rect A, SDL_Rect B){return sqrt(pow(A.x-B.x,2)+pow(A.y-B.y,2));}; list getNear(Creature C); private: - //vectors containing objects of each type - Window main = Window("no");//will be needed for adding R's and C's after constructor. + Window main = Window("do not create new window."); list R; list C; }; diff --git a/inc/location.hpp b/inc/location.hpp deleted file mode 100644 index 5392e9b..0000000 --- a/inc/location.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef location_h -#define location_h - -class Location -{ - public: - Location(int x1, int y1){x=x1;y=y1;}; - Location(){x=y=0;}; - int x; - int y; -}; - -#endif diff --git a/inc/main.hpp b/inc/main.hpp index d20f7ef..82a78c8 100644 --- a/inc/main.hpp +++ b/inc/main.hpp @@ -7,7 +7,6 @@ #include "creature.hpp" #include "resource.hpp" #include "list.hpp" -#include "location.hpp" #include "timer.hpp" #endif diff --git a/inc/resource.hpp b/inc/resource.hpp index 5f70585..ed9f098 100644 --- a/inc/resource.hpp +++ b/inc/resource.hpp @@ -2,16 +2,13 @@ #define resource_h #include "entity.hpp" -#include "location.hpp" class Resource: public Entity { public: - Resource(Window m, int size); - Resource(Window m, int size, Location z); + Resource(Window m, SDL_Rect Rect); void eat(); - Location getLocation(){return L;}; int getAmount(){return amount;}; private: -- cgit v1.2.3