diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-30 18:24:38 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-30 18:24:38 +0200 |
commit | 6e27f12e8f780a82f114b42088973363f9a896ff (patch) | |
tree | ca69f8e50c30e2bc41c3e8bdf9aa2ee5b1a77e0e /src/ft_bad_boy_actions.c | |
parent | It's moving! (diff) | |
download | 42-cub3d-6e27f12e8f780a82f114b42088973363f9a896ff.tar.gz 42-cub3d-6e27f12e8f780a82f114b42088973363f9a896ff.tar.bz2 42-cub3d-6e27f12e8f780a82f114b42088973363f9a896ff.tar.xz 42-cub3d-6e27f12e8f780a82f114b42088973363f9a896ff.tar.zst 42-cub3d-6e27f12e8f780a82f114b42088973363f9a896ff.zip |
Pretty coolio
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; } |