diff options
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 |