diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-31 14:29:18 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-31 14:29:18 +0200 |
commit | 137397e014be24d48ccc60e36af21ffc25229b77 (patch) | |
tree | 4cc7e8a39c7b92756efceea8ea155d5de29317f3 /src | |
parent | Nigga ain't gonna stop shootin me (diff) | |
download | 42-cub3d-137397e014be24d48ccc60e36af21ffc25229b77.tar.gz 42-cub3d-137397e014be24d48ccc60e36af21ffc25229b77.tar.bz2 42-cub3d-137397e014be24d48ccc60e36af21ffc25229b77.tar.xz 42-cub3d-137397e014be24d48ccc60e36af21ffc25229b77.tar.zst 42-cub3d-137397e014be24d48ccc60e36af21ffc25229b77.zip |
Fixed that gangsta
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_bad_boy_actions.c | 20 | ||||
-rw-r--r-- | src/ft_init_bad_boys.c | 2 | ||||
-rw-r--r-- | src/ft_key_loop.c | 22 | ||||
-rw-r--r-- | src/ft_select_bad_boy_action.c | 4 | ||||
-rw-r--r-- | src/ft_time.c | 3 |
5 files changed, 26 insertions, 25 deletions
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 @@ -62,6 +62,26 @@ void } 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) { (void)sl; 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 <stddef.h> #include <stdint.h> #include <time.h> - -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 <unistd.h> 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); } |