diff options
-rw-r--r-- | map/map_one.cub | 10 | ||||
-rw-r--r-- | src/ft_find_item.c | 30 | ||||
-rw-r--r-- | src/ft_get_sprite_spawns.c | 27 |
3 files changed, 39 insertions, 28 deletions
diff --git a/map/map_one.cub b/map/map_one.cub index 0935590..3d45184 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -30,17 +30,17 @@ SH 2 100000000000000000000000000001 1001000000T0000000000000000001 10110+0+0111000001110000000111 -111111111111110011 1000N0001 +111111111111110011 100000001 1000001 100001 111111111 1001001 100001 1011001 100001 111101111111110111 10000000110101011 10000000000000001 -1#000000000000001 -1@000000000000001 -1!000000000000001 +1#0#0#0#000000001 +1@0@0@0@000W00001 +1!0!0!0!000000001 10000000000000001 11000000110100011 -11110111111101011 +111101111111T1011 11111 1 1111 diff --git a/src/ft_find_item.c b/src/ft_find_item.c index 2d6f272..394e060 100644 --- a/src/ft_find_item.c +++ b/src/ft_find_item.c @@ -30,6 +30,22 @@ static uint16_t return (0); } +static uint16_t + ft_fetch_weaps_id(int8_t weap_id, uint64_t pos_y, uint64_t pos_x, t_cub *cl) +{ + uint16_t id; + + id = 0; + while (id <= 64) + { + if (cl->sprites[10 + weap_id][id].s_pos_y == pos_y && + cl->sprites[10 + weap_id][id].s_pos_x == pos_x) + return (id); + id++; + } + return (0); +} + static void ft_set_ammo(uint8_t weap_id, t_player *pl) { @@ -47,6 +63,7 @@ static void ft_weapon_check(const char map_char, t_player *pl, t_cub *cl) { uint8_t weap_id; + uint8_t that_id; if (ft_ischarset(FT_CHRST_WEAPONS, map_char)) { @@ -56,19 +73,16 @@ static void else if (map_char == '#') weap_id = 2; cl->mlist.map[(uint64_t)pl->pos_y][(uint64_t)pl->pos_x] = '0'; - cl->sprites[10 + weap_id][0].s_pos_x = 0; - cl->sprites[10 + weap_id][0].s_pos_y = 0; + that_id = ft_fetch_weaps_id(weap_id, (uint64_t)pl->pos_y, + (uint64_t)pl->pos_x, cl); + cl->sprites[10 + weap_id][that_id].s_pos_x = 0; + cl->sprites[10 + weap_id][that_id].s_pos_y = 0; pl->has_weapon[weap_id] = 1; pl->handles_weapon = (weap_id == 0) ? (0) : (pl->handles_weapon); pl->handles_weapon = (weap_id == 1) ? (2) : (pl->handles_weapon); pl->handles_weapon = (weap_id == 2) ? (4) : (pl->handles_weapon); ft_set_ammo(weap_id, pl); - if (weap_id == 0) - cl->sfx[6].sfx_play(cl->sfx); - else if (weap_id == 1) - cl->sfx[8].sfx_play(cl->sfx); - else if (weap_id == 2) - cl->sfx[10].sfx_play(cl->sfx); + cl->sfx[6 + (weap_id * 2)].sfx_play(cl->sfx); } } diff --git a/src/ft_get_sprite_spawns.c b/src/ft_get_sprite_spawns.c index 0d20664..9329c51 100644 --- a/src/ft_get_sprite_spawns.c +++ b/src/ft_get_sprite_spawns.c @@ -35,17 +35,17 @@ static void ft_check_amount(t_cub *cl, int s_n) { - if (s_n < 8 && cl->mlist.sprite_nbr[s_n] >= 4096) + if (s_n < 8 && cl->mlist.sprite_nbr[s_n] > 4096) ft_map_error(FT_ERR_TOO_MUCH_SPRT, cl); - else if (s_n == 8 && cl->mlist.sprite_nbr[s_n] >= 512) + else if (s_n == 8 && cl->mlist.sprite_nbr[s_n] > 512) ft_map_error(FT_ERR_TOO_MUCH_TRAPS, cl); - else if (s_n == 9 && cl->mlist.sprite_nbr[s_n] >= 64) + else if (s_n == 9 && cl->mlist.sprite_nbr[s_n] > 64) ft_map_error(FT_ERR_TOO_MUCH_HEALS, cl); - else if (s_n == 10 && cl->mlist.sprite_nbr[s_n] >= 4) + else if (s_n == 10 && cl->mlist.sprite_nbr[s_n] > 4) ft_map_error(FT_ERR_TOO_MUCH_W_ONE, cl); - else if (s_n == 11 && cl->mlist.sprite_nbr[s_n] >= 4) + else if (s_n == 11 && cl->mlist.sprite_nbr[s_n] > 4) ft_map_error(FT_ERR_TOO_MUCH_W_TWO, cl); - else if (s_n == 12 && cl->mlist.sprite_nbr[s_n] >= 4) + else if (s_n == 12 && cl->mlist.sprite_nbr[s_n] > 4) ft_map_error(FT_ERR_TOO_MUCH_W_THREE, cl); } @@ -56,15 +56,12 @@ static int8_t return (ft_get_next_sprite(cl, 8, 'T', 0)); if (s_n + 1 == 9) return (ft_get_next_sprite(cl, 9, '+', 0)); - if (cl->isdead == 0) - { - if (s_n + 1 == 10) - return (ft_get_next_sprite(cl, 10, '!', 0)); - if (s_n + 1 == 11) - return (ft_get_next_sprite(cl, 11, '@', 0)); - if (s_n + 1 == 12) - return (ft_get_next_sprite(cl, 12, '#', 0)); - } + if (s_n + 1 == 10) + return (ft_get_next_sprite(cl, 10, '!', 0)); + if (s_n + 1 == 11) + return (ft_get_next_sprite(cl, 11, '@', 0)); + if (s_n + 1 == 12) + return (ft_get_next_sprite(cl, 12, '#', 0)); return (0); } |