summaryrefslogtreecommitdiff
path: root/src/dna.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dna.cpp')
-rw-r--r--src/dna.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/dna.cpp b/src/dna.cpp
index ac2d500..4e22d7a 100644
--- a/src/dna.cpp
+++ b/src/dna.cpp
@@ -2,8 +2,9 @@
DNA::DNA(std::string s)
{
- if(s == "creature"){
- type = CREATURE_TYPE;
+ if(s == "herbavore"){
+ type = HERBAVORE_TYPE;
+ eatType = PLANT_TYPE;
maxHealth = CREATURE_MAX_HEALTH;
bestSense = CREATURE_BEST_SENSE;
bite = CREATURE_BITE;
@@ -16,11 +17,30 @@ DNA::DNA(std::string s)
mutationChance = CREATURE_MUTATION_CHANCE;
appearance.sides = CREATURE_SIDES;
appearance.red = 0;
- appearance.green = 1;
+ appearance.green = 0.5;
appearance.blue = 1;
}
- else if(s == "resource"){
- type = RESOURCE_TYPE;
+ else if(s == "carnivore"){
+ type = CARNIVORE_TYPE;
+ eatType = HERBAVORE_TYPE;
+ maxHealth = CREATURE_MAX_HEALTH * 2;
+ bestSense = CREATURE_BEST_SENSE * 2;
+ bite = CREATURE_BITE * 2;
+ expectedPregnancyTime = CREATURE_EXP_PREG_TIME;
+ expectedAge = CREATURE_EXP_AGE * 2;
+ growAmount = 0;
+ reach = CREATURE_REACH * 2;
+ speed = CREATURE_SPEED * 2;
+ mutationPercent = CREATURE_MUTATION_PERCENT;
+ mutationChance = CREATURE_MUTATION_CHANCE;
+ appearance.sides = CREATURE_SIDES;
+ appearance.red = 1;
+ appearance.green = 0;
+ appearance.blue = 0;
+ }
+ else if(s == "plant"){
+ type = PLANT_TYPE;
+ eatType = 0;
maxHealth = RESOURCE_MAX_HEALTH;
bestSense = 0;
bite = 0;
@@ -41,7 +61,8 @@ DNA::DNA(std::string s)
DNA DNA::combine(DNA D)
{
DNA N;
- N.type = CREATURE_TYPE;
+ N.type = type;
+ N.eatType = eatType;
N.maxHealth = (maxHealth + D.maxHealth)/2;
N.bestSense = (bestSense + D.bestSense)/2;
N.bite = (bite + D.bite)/2;
@@ -53,9 +74,9 @@ DNA DNA::combine(DNA D)
N.mutationPercent = (mutationPercent + D.mutationPercent)/2;
N.mutationChance = (mutationChance + D.mutationChance)/2;
N.appearance.sides = CREATURE_SIDES;
- N.appearance.red = 0;
- N.appearance.green = 1;
- N.appearance.blue = 1;
+ N.appearance.red = appearance.red;
+ N.appearance.green = appearance.green;
+ N.appearance.blue = appearance.blue;
if(roll(mutationChance)){
float pn;