diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-29 18:18:53 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-29 18:18:53 +0200 |
commit | de96c6521888b0c4ec7f8e8f715090e81ff921c2 (patch) | |
tree | 8982b497f4f01c983028100e77aa7e80380532b6 | |
parent | Gameplay update (diff) | |
download | 42-cub3d-de96c6521888b0c4ec7f8e8f715090e81ff921c2.tar.gz 42-cub3d-de96c6521888b0c4ec7f8e8f715090e81ff921c2.tar.bz2 42-cub3d-de96c6521888b0c4ec7f8e8f715090e81ff921c2.tar.xz 42-cub3d-de96c6521888b0c4ec7f8e8f715090e81ff921c2.tar.zst 42-cub3d-de96c6521888b0c4ec7f8e8f715090e81ff921c2.zip |
Fixed buggy shooting
Diffstat (limited to '')
-rw-r--r-- | src/ft_shoot.c | 34 |
1 files 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 @@ -14,6 +14,36 @@ #include <libft.h> 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) { while (hit == 0) @@ -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])) |