From de96c6521888b0c4ec7f8e8f715090e81ff921c2 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 29 Mar 2020 18:18:53 +0200 Subject: Fixed buggy shooting --- src/ft_shoot.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/ft_shoot.c b/src/ft_shoot.c index 82c3017..229b9e9 100644 --- a/src/ft_shoot.c +++ b/src/ft_shoot.c @@ -13,6 +13,36 @@ #include #include +static void + ft_hide_sprite(t_cub *cl) +{ + int64_t i; + int64_t j; + uint8_t stop; + + i = -1; + j = -1; + stop = 0; + while (++i < FT_TOTAL_SPRT - 5) + { + while (++j < 4096) + { + if (cl->sprites[i][j].s_pos_x == cl->rlist.sqy && + cl->sprites[i][j].s_pos_y == cl->rlist.sqx) + { + stop = 1; + break ; + } + } + if (stop == 1) + break ; + j = -1; + } + cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy] = '0'; + cl->sprites[i][j].s_pos_x = 0; + cl->sprites[i][j].s_pos_y = 0; +} + static void ft_hitscan(t_cub *cl, uint16_t hit) { @@ -34,8 +64,8 @@ static void cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy])) { hit = 1; - cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy] = '0'; - ft_get_sprite_spawn(cl); + ft_hide_sprite(cl); + /* ft_get_sprite_spawn(cl); */ } else if (ft_ischarset("1", cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy])) -- cgit v1.2.3