summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authortom <tombarrett@siu.edu>2017-02-12 05:59:12 -0600
committertom <tombarrett@siu.edu>2017-02-12 05:59:12 -0600
commitaa5c31be6ec6a688e8d3a66c770ba99be8e060c9 (patch)
tree702a7154031cb9c96d0e7fd495868418433bb842 /inc
parent60b53e09cca0bdb4cddff76457e990ee33c42b2f (diff)
-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
Diffstat (limited to 'inc')
-rw-r--r--inc/constants.hpp44
-rw-r--r--inc/creature.hpp23
-rw-r--r--inc/dna.hpp21
-rw-r--r--inc/list.hpp6
-rw-r--r--inc/window.hpp4
5 files changed, 55 insertions, 43 deletions
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<Entity*> n){N = n;};
+ void giveN(std::list<Entity*> 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<Entity*> N;
+ SDL_Rect wTarget;
+ Entity *target;
+ std::list<Entity*> 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<Entity*> getNear(Creature C);
+ std::list<Entity*> getNear(Creature C);
private:
Window main = Window("do not create new window.");
- list<Resource> R;
- list<Creature> C;
+ std::list<Resource> R;
+ std::list<Creature> 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();