diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-30 21:16:48 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-30 21:16:48 +0200 |
commit | 14b08c7f6a5fc0efa61af63ef651fd444b00b697 (patch) | |
tree | b8b0f72d26d615f7cc5e6c3c6e7fa96a593753a3 /src/ft_key_loop.c | |
parent | Fine (diff) | |
download | 42-cub3d-14b08c7f6a5fc0efa61af63ef651fd444b00b697.tar.gz 42-cub3d-14b08c7f6a5fc0efa61af63ef651fd444b00b697.tar.bz2 42-cub3d-14b08c7f6a5fc0efa61af63ef651fd444b00b697.tar.xz 42-cub3d-14b08c7f6a5fc0efa61af63ef651fd444b00b697.tar.zst 42-cub3d-14b08c7f6a5fc0efa61af63ef651fd444b00b697.zip |
Nigga be shootin' quick af
Diffstat (limited to 'src/ft_key_loop.c')
-rw-r--r-- | src/ft_key_loop.c | 81 |
1 files changed, 12 insertions, 69 deletions
diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c index eb020da..dad6467 100644 --- a/src/ft_key_loop.c +++ b/src/ft_key_loop.c @@ -17,82 +17,24 @@ #include <stdint.h> #include <time.h> -static uint64_t - ft_find_x(int32_t key, const t_player *pl) -{ - if (key == 0) - return (pl->pos_x + (pl->dir_y * FT_COLL_MULT)); - else if (key == 1) - return (pl->pos_x + (pl->dir_x * (FT_COLL_MULT / 2))); - else if (key == 2) - return (pl->pos_x - (pl->dir_y * FT_COLL_MULT)); - else if (key == 3) - return (pl->pos_x - (pl->dir_x * (FT_COLL_MULT / 2))); - return ((uint64_t)pl->pos_x); -} - -static uint64_t - ft_find_y(int32_t key, const t_player *pl) -{ - if (key == 0) - return (pl->pos_y + (pl->dir_x * FT_COLL_MULT)); - else if (key == 1) - return (pl->pos_y - (pl->dir_y * (FT_COLL_MULT / 2))); - else if (key == 2) - return (pl->pos_y - (pl->dir_x * FT_COLL_MULT)); - else if (key == 3) - return (pl->pos_y + (pl->dir_y * (FT_COLL_MULT / 2))); - return ((uint64_t)pl->pos_y); -} - static void - ft_collision(double old_y, double old_x, int32_t key, t_cub *cl) + ft_check_bad_boy_shoot(t_cub *cl) { - uint64_t x; - uint64_t y; - - x = ft_find_x(key, &cl->plist); - y = ft_find_y(key, &cl->plist); - if (cl->mlist.map[y][x] == 'T') - { - cl->plist.pos_x = old_x + ((old_x - x) / 2); - cl->plist.pos_y = old_y + ((old_y - y) / 2); - if (FT_OS == 1) - ft_macos_suffer_animation(cl); - else - ft_linux_suffer_animation(cl); - x = ft_find_x(key, &cl->plist); - y = ft_find_y(key, &cl->plist); - } - if (ft_ischarset(FT_CHRST_COLLISION, cl->mlist.map[(uint64_t)old_y][x]) || - cl->mlist.map[(uint64_t)old_y][x] == '\0') - cl->plist.pos_x = old_x; - if (ft_ischarset(FT_CHRST_COLLISION, cl->mlist.map[y][(uint64_t)old_x]) || - cl->mlist.map[y][(uint64_t)old_x] == '\0') - cl->plist.pos_y = old_y; -} + int8_t i; -static int - ft_handle_keys(uint8_t i, float old_y, float old_x, t_cub *cl) -{ - cl->key_ptr[cl->key_input[i]](cl); - if (cl->key_input[i] >= 0 && cl->key_input[i] <= 3) + i = 0; + while (i < cl->mlist.sprite_nbr[13]) { - cl->sfx[1].sfx_play(cl->sfx); - ft_collision(old_y, old_x, cl->key_input[i], cl); - ft_find_item(&cl->plist, &cl->mlist, cl); - if (cl->mlist.isnlvl) + if (cl->bad_boy[i].does == 2) { - if ((uint32_t)cl->plist.pos_x == cl->mlist.nlx && - (uint32_t)cl->plist.pos_y == cl->mlist.nly) - { - cl->sfx[2].sfx_play(cl->sfx); - return ((ft_warp_level(cl->mlist.nlevel_path, cl) < 0) ? - (ft_exit(FT_RET_FAILED_STRUCTS, cl)) : (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++; } - return (0); } int @@ -109,6 +51,7 @@ int ft_handle_keys(i, old_y, old_x, cl); i++; } + ft_check_bad_boy_shoot(cl); cl->moves = (cl->key_input[0] == -1) ? (0) : (cl->moves); begin_frame = clock(); ft_draw_scene(cl); |