From 137397e014be24d48ccc60e36af21ffc25229b77 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 31 Mar 2020 14:29:18 +0200 Subject: Fixed that gangsta --- src/ft_bad_boy_actions.c | 20 ++++++++++++++++++++ src/ft_init_bad_boys.c | 2 +- src/ft_key_loop.c | 22 ++-------------------- src/ft_select_bad_boy_action.c | 4 ++-- src/ft_time.c | 3 +-- 5 files changed, 26 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/ft_bad_boy_actions.c b/src/ft_bad_boy_actions.c index 3e961fb..c2324bd 100644 --- a/src/ft_bad_boy_actions.c +++ b/src/ft_bad_boy_actions.c @@ -61,6 +61,26 @@ void bl->does = 1; } +void + ft_check_bad_boy_shoot(t_cub *cl) +{ + int8_t i; + + i = 0; + while (i < cl->mlist.sprite_nbr[13]) + { + if (cl->bad_boy[i].does == 2 && cl->bad_boy[i].sleep == 0) + { + cl->sfx[11].sfx_play(cl->sfx); + if (FT_OS == 1) + ft_macos_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); + else + ft_linux_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); + } + i++; + } +} + void ft_bb_fire(t_bad_boy *bl, t_sprite *sl, t_map *ml) { diff --git a/src/ft_init_bad_boys.c b/src/ft_init_bad_boys.c index ef67498..100411e 100644 --- a/src/ft_init_bad_boys.c +++ b/src/ft_init_bad_boys.c @@ -35,7 +35,7 @@ int8_t i = 0; while (i < cl->mlist.sprite_nbr[13]) { - cl->bad_boy[i].life = 5; + cl->bad_boy[i].life = FT_ENMY_STRT_LIFE; cl->bad_boy[i].does = 0; cl->bad_boy[i].sleep = 0; cl->bad_boy[i].act[0] = ft_bb_wait; diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c index dad6467..281c81e 100644 --- a/src/ft_key_loop.c +++ b/src/ft_key_loop.c @@ -16,26 +16,7 @@ #include #include #include - -static void - ft_check_bad_boy_shoot(t_cub *cl) -{ - int8_t i; - - i = 0; - while (i < cl->mlist.sprite_nbr[13]) - { - if (cl->bad_boy[i].does == 2) - { - cl->sfx[11].sfx_play(cl->sfx); - if (FT_OS == 1) - ft_macos_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); - else - ft_linux_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); - } - i++; - } -} +#include int ft_key_loop(t_cub *cl) @@ -56,5 +37,6 @@ int begin_frame = clock(); ft_draw_scene(cl); ft_timings(begin_frame, cl); + ft_get_fps_count(begin_frame, cl); return (0); } diff --git a/src/ft_select_bad_boy_action.c b/src/ft_select_bad_boy_action.c index db75208..73b3f9a 100644 --- a/src/ft_select_bad_boy_action.c +++ b/src/ft_select_bad_boy_action.c @@ -27,7 +27,7 @@ ** I. player is not in sight ** rand(0-3) | [0-2] wait | [3] walk ** II. player is in sight -** rand(0-7) | [0-1] wait | [2-3] walk | [4-7] fire +** rand(0-7) | [0-1] wait | [2] walk | [3-7] fire */ static double @@ -64,7 +64,7 @@ static int8_t r = rand() % 8; if (r <= 1) return (0); - else if (r >= 2 && r <= 3) + else if (r == 2) return (1); else return (2); diff --git a/src/ft_time.c b/src/ft_time.c index ea0d221..a2ab4a0 100644 --- a/src/ft_time.c +++ b/src/ft_time.c @@ -45,7 +45,7 @@ void curr = clock(); dt[i] += curr - before; - if (cl->bad_boy[i].sleep == 1 && dt[i] > 0 && ft_clock_to_ms(dt[i]) > 1500) + if (cl->bad_boy[i].sleep == 1 && dt[i] > 0 && ft_clock_to_ms(dt[i]) > 700.0) { cl->bad_boy[i].sleep = 0; dt[i] = 0; @@ -65,5 +65,4 @@ void ft_bad_boys_time(before, i, cl); i++; } - ft_get_fps_count(before, cl); } -- cgit v1.2.3