From a9281bfcf21861e621a3243ecb633a299c8d8e52 Mon Sep 17 00:00:00 2001 From: tom Date: Sat, 21 Jan 2017 08:58:12 -0600 Subject: -took basic math functions and put it into functions.hpp -spaced various lines -reorganized variables by datatype -implemented reproduction -reorganized pathing so once a target is set, the creature checks if that same target is near every cycle --- inc/functions.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 inc/functions.hpp (limited to 'inc/functions.hpp') diff --git a/inc/functions.hpp b/inc/functions.hpp new file mode 100644 index 0000000..2ddcda9 --- /dev/null +++ b/inc/functions.hpp @@ -0,0 +1,12 @@ +#ifndef functions_h +#define functions_h + +static double Distance(SDL_Rect A, SDL_Rect B){ + return sqrt( pow(A.x-B.x,2) + pow(A.y-B.y,2)); +} + +static int map(int x, int inMin, int inMax, int outMin, int outMax){ + return (x-inMin) * (outMax - outMin) / (inMax - inMin) + outMin; +} + +#endif -- cgit v1.2.3