diff options
Diffstat (limited to '')
-rw-r--r-- | map/map_seven.cub | 1 | ||||
-rw-r--r-- | src/ft_bad_boy_actions.c | 21 | ||||
-rw-r--r-- | src/ft_select_bad_boy_action.c | 5 | ||||
-rw-r--r-- | src/ft_time.c | 28 |
4 files changed, 34 insertions, 21 deletions
diff --git a/map/map_seven.cub b/map/map_seven.cub index a72ca1c..636d923 100644 --- a/map/map_seven.cub +++ b/map/map_seven.cub @@ -5,6 +5,7 @@ SO ./media/img/tex/plate_small.xpm EA ./media/img/tex/plate_small.xpm WE ./media/img/tex/plate_small.xpm S ./media/img/sprites/pillar.xpm +S3 ./media/img/sprites/spikes.xpm F 150,150,150 C 150,150,150 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; } diff --git a/src/ft_select_bad_boy_action.c b/src/ft_select_bad_boy_action.c index 6b3d2ef..34e0efe 100644 --- a/src/ft_select_bad_boy_action.c +++ b/src/ft_select_bad_boy_action.c @@ -25,7 +25,10 @@ void { if (cl->bad_boy[i].sleep == 0 && cl->bad_boy[i].life > 0) { - r = rand() % 2; + if (FT_OS == 2) + r = random() % 2; + else + r = rand() % 2; cl->bad_boy[i].act[r](&cl->bad_boy[i], &cl->sprites[13][i], &cl->mlist); cl->bad_boy[i].sleep = 1; diff --git a/src/ft_time.c b/src/ft_time.c index d175bbf..4d33dc8 100644 --- a/src/ft_time.c +++ b/src/ft_time.c @@ -38,32 +38,32 @@ void } void - ft_bad_boys_time(clock_t before, t_cub *cl) + ft_bad_boys_time(clock_t before, int8_t i, t_cub *cl) { - int8_t i; - static clock_t dt = 0; + static clock_t dt[32]; clock_t curr; curr = clock(); - dt += curr - before; - i = 0; - while (i < cl->mlist.sprite_nbr[13]) + dt[i] += curr - before; + if (cl->bad_boy[i].sleep == 1 && dt[i] > 0 && ft_clock_to_ms(dt[i]) > 700.0) { - if (cl->bad_boy[i].sleep == 1 && dt > 0 && ft_clock_to_ms(dt) > 600.0) - { - cl->bad_boy[i].sleep = 0; - dt = 0; - } - i++; + cl->bad_boy[i].sleep = 0; + dt[i] = 0; } } void ft_timings(clock_t before, t_cub *cl) { + int8_t i; + + i = 0; if (cl->plist.fire == 1) ft_handle_firing(before, cl); - if (cl->mlist.sprite_nbr[13] > 0) - ft_bad_boys_time(before, cl); + while (i < cl->mlist.sprite_nbr[13]) + { + ft_bad_boys_time(before, i, cl); + i++; + } ft_get_fps_count(before, cl); } |