diff options
Diffstat (limited to 'src/ft_bad_boy_actions.c')
-rw-r--r-- | src/ft_bad_boy_actions.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/ft_bad_boy_actions.c b/src/ft_bad_boy_actions.c index 6b7b3bf..775e917 100644 --- a/src/ft_bad_boy_actions.c +++ b/src/ft_bad_boy_actions.c @@ -13,6 +13,7 @@ #include <libft.h> #include <cub3d.h> #include <stdlib.h> +#include <math.h> void ft_bb_wait(t_bad_boy *bl, t_sprite *sl, t_map *ml) @@ -40,13 +41,21 @@ void const double old_x = sl->s_pos_x; const double old_y = sl->s_pos_y; - r_x = (rand() % 2 == 1) ? (1) : (-1); - r_y = (rand() % 2 == 1) ? (1) : (-1); - sl->s_pos_x += 0.3 * (r_x); - sl->s_pos_y += 0.3 * (r_y); + if (FT_OS == 2) + { + r_x = (random() % 2 == 1) ? (1) : (-1); + r_y = (random() % 2 == 1) ? (1) : (-1); + } + else + { + r_x = (rand() % 2 == 1) ? (1) : (-1); + r_y = (rand() % 2 == 1) ? (1) : (-1); + } + sl->s_pos_x += (0.1 * r_x); + sl->s_pos_y += (0.1 * r_y); ft_bb_collision(old_y, old_x, sl, ml); - ml->map[(uint64_t)old_y][(uint64_t)old_x] = '0'; - ml->map[(uint64_t)sl->s_pos_y][(uint64_t)sl->s_pos_x] = 'e'; + ml->map[lround(old_y)][lround(old_x)] = '0'; + ml->map[lround(sl->s_pos_y)][lround(sl->s_pos_x)] = 'e'; bl->does = 1; } |