diff options
author | majortom6 <tombarrett@siu.edu> | 2017-02-19 12:00:52 -0600 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-03-07 13:23:41 -0600 |
commit | 0846d5802965d257f176e033d7a6ac353ed648f3 (patch) | |
tree | 1ada2e260970883decd2165d3dd3b74ad34212fd /inc | |
parent | bfdc713b68dd6f8d61e7b26fc2cff15caf24b44d (diff) |
-speedcaps now working again
-creatures now randomize target better again
-thats enough for today, src is still a mess and main can be cleaned a bit
Diffstat (limited to 'inc')
-rw-r--r-- | inc/creature.hpp | 6 | ||||
-rw-r--r-- | inc/functions.hpp | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/inc/creature.hpp b/inc/creature.hpp index 0f9128f..01f6557 100644 --- a/inc/creature.hpp +++ b/inc/creature.hpp @@ -2,7 +2,9 @@ #define creature_h #include <cstdlib> +#include <vector> #include <list> +#include <algorithm> #include "entity.hpp" #include "functions.hpp" @@ -19,7 +21,7 @@ class Creature: public Entity void checkTarget(); void moveTowards(Rectangle t); void impregnate(DNA D); - void giveNearMe(std::list<Entity*> n){nearMe = n;}; + void giveNearMe(std::list<Entity*> n){nearMe = {std::begin(n),std::end(n)};}; DNA getDNA(){return myDNA;}; DNA getChildsDNA(){return childsDNA;}; @@ -32,7 +34,7 @@ class Creature: public Entity private: Rectangle wTarget; Entity* target; - std::list<Entity*> nearMe; + std::vector<Entity*> nearMe; DNA myDNA; DNA childsDNA; diff --git a/inc/functions.hpp b/inc/functions.hpp index 7ce9f8d..b0ecb65 100644 --- a/inc/functions.hpp +++ b/inc/functions.hpp @@ -13,4 +13,8 @@ static int map(int x, int inMin, int inMax, int outMin, int outMax){ return (x-inMin) * (outMax - outMin) / (inMax - inMin) + outMin; } +static float getRandom(float x){ + return (-x + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(x-(-x))))); +} + #endif |