From 836f56a40fa4a2b8e68c23b2c299e50fefe0c15d Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Sun, 12 Mar 2017 11:07:22 -0500 Subject: -renamed constants to fit new datatypes -reimplemented corpses -implemented hunger and starving (if creature is starving they will eat corpses and will take damage) -removed sides data from dna (think it is irrelavent) -removed data from dna that is not used for plants --- src/dna.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'src/dna.cpp') diff --git a/src/dna.cpp b/src/dna.cpp index 4e22d7a..dd1d606 100644 --- a/src/dna.cpp +++ b/src/dna.cpp @@ -10,52 +10,50 @@ DNA::DNA(std::string s) bite = CREATURE_BITE; expectedPregnancyTime = CREATURE_EXP_PREG_TIME; expectedAge = CREATURE_EXP_AGE; - growAmount = 0; + hungryAmount = CREATURE_HUNGRY_AMOUNT; + starveAmount = CREATURE_STARVE_AMOUNT; reach = CREATURE_REACH; speed = CREATURE_SPEED; mutationPercent = CREATURE_MUTATION_PERCENT; mutationChance = CREATURE_MUTATION_CHANCE; - appearance.sides = CREATURE_SIDES; appearance.red = 0; - appearance.green = 0.5; + appearance.green = 1; appearance.blue = 1; } else if(s == "carnivore"){ type = CARNIVORE_TYPE; eatType = HERBAVORE_TYPE; - maxHealth = CREATURE_MAX_HEALTH * 2; + maxHealth = CREATURE_MAX_HEALTH; bestSense = CREATURE_BEST_SENSE * 2; bite = CREATURE_BITE * 2; expectedPregnancyTime = CREATURE_EXP_PREG_TIME; expectedAge = CREATURE_EXP_AGE * 2; - growAmount = 0; + hungryAmount = CREATURE_HUNGRY_AMOUNT; + starveAmount = CREATURE_STARVE_AMOUNT; 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; + appearance.blue = 1; } else if(s == "plant"){ type = PLANT_TYPE; - eatType = 0; - maxHealth = RESOURCE_MAX_HEALTH; - bestSense = 0; - bite = 0; - expectedPregnancyTime = 0; - expectedAge = 0; - growAmount = RESOURCE_GROW_AMOUNT; - reach = 0; - speed = 0; - mutationPercent = 0; - mutationChance = 0; - appearance.sides = RESOURCE_SIDES; + maxHealth = PLANT_MAX_HEALTH; + growAmount = PLANT_GROW_AMOUNT; appearance.red = 0; appearance.green = 1; appearance.blue = 0; } + else if(s == "corpse"){ + type = CORPSE_TYPE; + maxHealth = CORPSE_MAX_HEALTH; + growAmount = CORPSE_DECAY_AMOUNT; + appearance.red = 0; + appearance.green = 0; + appearance.blue = 1; + } } DNA DNA::combine(DNA D) @@ -69,11 +67,12 @@ DNA DNA::combine(DNA D) N.expectedPregnancyTime = (expectedPregnancyTime + D.expectedPregnancyTime)/2; N.expectedAge = (expectedAge + D.expectedAge)/2; N.growAmount = (growAmount + D.growAmount)/2; + N.hungryAmount = (hungryAmount + D.hungryAmount)/2; + N.starveAmount = (starveAmount + D.starveAmount)/2; N.reach = (reach + D.reach)/2; N.speed = (speed + D.speed)/2; N.mutationPercent = (mutationPercent + D.mutationPercent)/2; N.mutationChance = (mutationChance + D.mutationChance)/2; - N.appearance.sides = CREATURE_SIDES; N.appearance.red = appearance.red; N.appearance.green = appearance.green; N.appearance.blue = appearance.blue; -- cgit v1.2.3