diff options
author | tom <tombarrett@siu.edu> | 2017-01-19 13:33:46 -0600 |
---|---|---|
committer | tom <tombarrett@siu.edu> | 2017-01-19 13:33:46 -0600 |
commit | 11c5d147b845d4323f2e94c1ac47b6001420d8e6 (patch) | |
tree | eafc67bb6844dc14b56ad5d8eadf6d200b78e0d1 /inc | |
parent | 0c2335f4a717e53c2456e49407dfbbd0ffa20f06 (diff) |
-added entity growing
-added bite functionality for creature/resource
-added gender (next largest feature is reproduction)
-refractored creature setTarget function to make more sense
-added constants for starting size of entity and max size of entity
-refractored list to make make much more sense
-added constants for types
Diffstat (limited to 'inc')
-rw-r--r-- | inc/constants.hpp | 35 | ||||
-rw-r--r-- | inc/creature.hpp | 33 | ||||
-rw-r--r-- | inc/entity.hpp | 2 | ||||
-rw-r--r-- | inc/list.hpp | 1 | ||||
-rw-r--r-- | inc/resource.hpp | 5 |
5 files changed, 47 insertions, 29 deletions
diff --git a/inc/constants.hpp b/inc/constants.hpp index 08f548e..45ff0e7 100644 --- a/inc/constants.hpp +++ b/inc/constants.hpp @@ -1,20 +1,29 @@ #ifndef constants_h #define constants_h -const int CREATURES = 10; -const int RESOURCES = 100; -const int MINIMUM_RESOURCES = 90; -const int WINDOW_X = 1080; -const int WINDOW_Y = 640; +const int CREATURES = 10; +const int RESOURCES = 100; +const int MINIMUM_RESOURCES = 90; +const int WINDOW_X = 1080; +const int WINDOW_Y = 640; -const int CREATURE_START_HEALTH = 500; -const int CREATURE_MAX_HEALTH = 1000; -const int CREATURE_BEST_SENSE = 100; -const int CREATURE_SPEED = 1; -const int CREATURE_REACH = 5; -const int CREATURE_SIZE = 10; +const int CREATURE_TYPE = 1; +const int RESOURCE_TYPE = 2; -const int RESOURCE_SIZE = 5; -const int RESOURCE_AMOUNT = 100; +const int CREATURE_START_HEALTH = 500; +const int CREATURE_MAX_HEALTH = 1000; +const int CREATURE_BEST_SENSE = 100; +const int CREATURE_SPEED = 1; +const int CREATURE_REACH = 5; +const int CREATURE_SIZE_MAX = 20; +const int CREATURE_SIZE_START = 10; +const int CREATURE_BITE = 10; +const int CREATURE_AMOUNT_TO_GROW = 50; + +const int RESOURCE_SIZE_START = 5; +const int RESOURCE_SIZE_MAX = 10; +const int RESOURCE_AMOUNT_START = 100; +const int RESOURCE_AMOUNT_MAX = 200; +const int RESOURCE_GROW = 1; #endif diff --git a/inc/creature.hpp b/inc/creature.hpp index f51d083..edc253f 100644 --- a/inc/creature.hpp +++ b/inc/creature.hpp @@ -17,24 +17,29 @@ class Creature: public Entity void setTarget(); void Move(SDL_Rect R); - void giveN(list<Entity*> n){N = n;}; - 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;}; + void giveN(list<Entity*> n){N = n;}; + 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;}; private: - bool hasTarget; - bool wander; + bool hasTarget; + bool wander; SDL_Rect wTarget; - int health; - int reach; - int maxHealth; - bool hungry; - int speed; - bool able; - int bestSense; + int health; + int reach; + int maxHealth; + int speed; + int bestSense; + int bite; + int amountAte; + int amountToGrow; + + bool hungry; + bool gender; + bool able; list<Entity*> N; Entity *target; diff --git a/inc/entity.hpp b/inc/entity.hpp index 5941a9c..6587f11 100644 --- a/inc/entity.hpp +++ b/inc/entity.hpp @@ -11,7 +11,7 @@ class Entity int getType(){return type;}; SDL_Rect getRect(){return rect;}; - virtual void eat(void){}; + virtual void eat(int bite){}; virtual int getAmount(void){}; protected: diff --git a/inc/list.hpp b/inc/list.hpp index 6800b34..64ca522 100644 --- a/inc/list.hpp +++ b/inc/list.hpp @@ -15,6 +15,7 @@ class List List(Window m); void Behavior(); void Place(); + void Remove(); double Distance(SDL_Rect A, SDL_Rect B){return sqrt(pow(A.x-B.x,2)+pow(A.y-B.y,2));}; list<Entity*> getNear(Creature C); diff --git a/inc/resource.hpp b/inc/resource.hpp index ed9f098..5c740fa 100644 --- a/inc/resource.hpp +++ b/inc/resource.hpp @@ -7,12 +7,15 @@ class Resource: public Entity { public: Resource(Window m, SDL_Rect Rect); - void eat(); + void eat(int bite); int getAmount(){return amount;}; + void grow(); + int map(int x, int inMin, int inMax, int outMin, int outMax); private: int amount; + int growAmount; }; #endif |