From 60bc5dcb19a983e8ae335ba89f860c59473303fb Mon Sep 17 00:00:00 2001 From: tom Date: Sun, 12 Feb 2017 08:42:55 -0600 Subject: -added DNA combining, currently it just takes the average of the mother and father -there maybe a random segfault, further investigation is needed --- inc/creature.hpp | 12 +++++++----- inc/dna.hpp | 1 + inc/entity.hpp | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/creature.hpp b/inc/creature.hpp index c3ed2d8..56954fe 100644 --- a/inc/creature.hpp +++ b/inc/creature.hpp @@ -20,10 +20,11 @@ class Creature: public Entity void setTarget(); void checkTarget(); void Move(SDL_Rect R); - void impregnate(); + void impregnate(Dna D); void giveN(std::vector n){N = n;}; Dna getDNA(){return mine;}; + Dna getChildDNA(){return childs;}; int getHealth(){return health;}; int getBestSense(){return mine.bestSense;}; bool getGender(){return gender;}; @@ -31,10 +32,11 @@ class Creature: public Entity void hadPregnancy(){pregnate = pregnancyReady = false;}; private: - SDL_Rect wTarget; - Entity *target; - std::vectorN; - Dna mine; + SDL_Rect wTarget; + Entity *target; + std::vector N; + Dna mine; + Dna childs; int health; int amountAte; diff --git a/inc/dna.hpp b/inc/dna.hpp index 4924e15..cd76731 100644 --- a/inc/dna.hpp +++ b/inc/dna.hpp @@ -7,6 +7,7 @@ class Dna { public: Dna(); + Dna combine(Dna D); int maxHealth; int speed; int reach; diff --git a/inc/entity.hpp b/inc/entity.hpp index a7b7f58..0eb8f60 100644 --- a/inc/entity.hpp +++ b/inc/entity.hpp @@ -2,6 +2,7 @@ #define entity_h #include "window.hpp" +#include "dna.hpp" class Entity { @@ -12,7 +13,7 @@ class Entity SDL_Rect getRect(){return rect;}; virtual void eat(int bite){}; - virtual void impregnate(void){}; + virtual void impregnate(Dna D){}; virtual bool getGender(void){}; virtual int getAmount(void){}; -- cgit v1.2.3