From aa5c31be6ec6a688e8d3a66c770ba99be8e060c9 Mon Sep 17 00:00:00 2001 From: tom Date: Sun, 12 Feb 2017 05:59:12 -0600 Subject: -minor constant changes -implemented dna structure, which carries the creatures attributes suchas speed and reach -currently a child inherits 100% the same dna as the mother -removed sing namespace std --- inc/constants.hpp | 44 +++++++++++++++++++++----------------------- inc/creature.hpp | 23 +++++++++-------------- inc/dna.hpp | 21 +++++++++++++++++++++ inc/list.hpp | 6 +++--- inc/window.hpp | 4 +--- 5 files changed, 55 insertions(+), 43 deletions(-) create mode 100644 inc/dna.hpp (limited to 'inc') diff --git a/inc/constants.hpp b/inc/constants.hpp index 5ec55b2..fd3413b 100644 --- a/inc/constants.hpp +++ b/inc/constants.hpp @@ -1,31 +1,29 @@ #ifndef constants_h #define constants_h -const int CREATURES = 10; -const int RESOURCES = 100; -const int MINIMUM_RESOURCES = 80; -const int WINDOW_X = 500; -const int WINDOW_Y = 500; +const int CREATURES = 10; +const int RESOURCES = 100; +const int MINIMUM_RESOURCES = 80; +const int WINDOW_X = 500; +const int WINDOW_Y = 500; -const int CREATURE_TYPE = 1; -const int RESOURCE_TYPE = 2; +const int CREATURE_TYPE = 1; +const int RESOURCE_TYPE = 2; -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 = 10; -const int CREATURE_SIZE_START = 5; -const int CREATURE_BITE = 10; -const int CREATURE_AMOUNT_TO_GROW = 50; -const int CREATURE_EXPECTED_PREGNANCY_TIME = 100; -const int CREATURE_EXPECTED_AGE = 100000; +const int CREATURE_MAX_HEALTH = 1000; +const int CREATURE_SPEED = 1; +const int CREATURE_REACH = 5; +const int CREATURE_BEST_SENSE = 100; +const int CREATURE_BITE = 10; +const int CREATURE_AMOUNT_TO_GROW = 50; +const int CREATURE_EXP_PREG_TIME = 100; +const int CREATURE_EXP_AGE = 1000000; +const int CREATURE_SIZE_MAX = 10; -const int RESOURCE_SIZE_START = 1; -const int RESOURCE_SIZE_MAX = 4; -const int RESOURCE_AMOUNT_START = 100; -const int RESOURCE_AMOUNT_MAX = 200; -const int RESOURCE_GROW = 1; +const int RESOURCE_SIZE_START = 1; +const int RESOURCE_SIZE_MAX = 4; +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 1676be0..95b1329 100644 --- a/inc/creature.hpp +++ b/inc/creature.hpp @@ -7,11 +7,12 @@ #include "entity.hpp" #include "constants.hpp" #include "functions.hpp" +#include "dna.hpp" class Creature: public Entity { public: - Creature(Window m, SDL_Rect R); + Creature(Window M, SDL_Rect R, Dna D); void Behavior(); void Action(); void Priority(); @@ -19,31 +20,25 @@ class Creature: public Entity void checkTarget(); void Move(SDL_Rect R); void impregnate(); - void giveN(list n){N = n;}; + void giveN(std::list n){N = n;}; + Dna getDNA(){return mine;}; int getHealth(){return health;}; - int getBestSense(){return bestSense;}; + int getBestSense(){return mine.bestSense;}; bool getGender(){return gender;}; bool getPregnancyReady(){return pregnancyReady;}; void hadPregnancy(){pregnate = pregnancyReady = false;}; private: - SDL_Rect wTarget; - Entity *target; - list N; + SDL_Rect wTarget; + Entity *target; + std::list N; + Dna mine; int health; - int reach; - int maxHealth; - int speed; - int bestSense; - int bite; int amountAte; - int amountToGrow; int pregnancyTime; - int expectedPregnancyTime; int age; - int expectedAge; bool hungry; bool pregnancyReady; diff --git a/inc/dna.hpp b/inc/dna.hpp new file mode 100644 index 0000000..4924e15 --- /dev/null +++ b/inc/dna.hpp @@ -0,0 +1,21 @@ +#ifndef dna_h +#define dna_h + +#include "constants.hpp" + +class Dna +{ + public: + Dna(); + int maxHealth; + int speed; + int reach; + int bestSense; + int bite; + int amountToGrow; + int expectedPregnancyTime; + int expectedAge; + int sizeMax; +}; + +#endif diff --git a/inc/list.hpp b/inc/list.hpp index cc78031..7d3d8a2 100644 --- a/inc/list.hpp +++ b/inc/list.hpp @@ -17,12 +17,12 @@ class List void Behavior(); void Place(); void Remove(); - list getNear(Creature C); + std::list getNear(Creature C); private: Window main = Window("do not create new window."); - list R; - list C; + std::list R; + std::list C; }; #endif diff --git a/inc/window.hpp b/inc/window.hpp index 1a1a5a7..b7ec500 100644 --- a/inc/window.hpp +++ b/inc/window.hpp @@ -6,13 +6,11 @@ #include "constants.hpp" -using namespace std; - class Window { public: Window(); - Window(string){}; + Window(std::string){}; void Destroy(); void Clear(); -- cgit v1.2.3