diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_sprite_spawns.c | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/src/ft_get_sprite_spawns.c b/src/ft_get_sprite_spawns.c index 8a92a3c..047523a 100644 --- a/src/ft_get_sprite_spawns.c +++ b/src/ft_get_sprite_spawns.c @@ -17,22 +17,47 @@ /* ** cl->sprite[] index summary ** -------------------------- -** 0: sprite 2 - tlist[4] -** 1: sprite 3 - tlist[8] -** 2: sprite 4 - tlist[9] -** 3: sprite 5 - tlist[10] -** 4: sprite 6 - tlist[11] -** 5: sprite 7 - tlist[12] -** 6: sprite 8 - tlist[13] -** 7: sprite 9 - tlist[14] -** 8: trap - tlist[15] -** 9: heal - tlist[17] -** 10: weapon one - tlist[18] -** 11: weapon two - tlist[19] -** 12: weapon three - tlist[20] +** 0: sprite 2 - tlist[4] - 4096 +** 1: sprite 3 - tlist[8] - 4096 +** 2: sprite 4 - tlist[9] - 4096 +** 3: sprite 5 - tlist[10] - 4096 +** 4: sprite 6 - tlist[11] - 4096 +** 5: sprite 7 - tlist[12] - 4096 +** 6: sprite 8 - tlist[13] - 4096 +** 7: sprite 9 - tlist[14] - 4096 +** 8: trap - tlist[15] - 512 +** 9: heal - tlist[17] - 64 +** 10: weapon one - tlist[18] - 4 +** 11: weapon two - tlist[19] - 4 +** 12: weapon three - tlist[20] - 4 */ -void +static void + ft_check_amount(t_cub *cl, int s_n) +{ + 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) + ft_map_error(FT_ERR_TOO_MUCH_TRAPS, cl); + 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) + ft_map_error(FT_ERR_TOO_MUCH_W_ONE, cl); + 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) + ft_map_error(FT_ERR_TOO_MUCH_W_THREE, cl); +} + +static int8_t + ft_other_next_sprite(t_cub *cl, int s_n) +{ + if (s_n == 7) + return (ft_get_next_sprite(cl, 8, 'T', 0)); + return (0); +} + +int8_t ft_get_next_sprite(t_cub *clist, int s_n, char c, size_t x) { size_t y; @@ -55,11 +80,11 @@ void } x = 0; } + ft_check_amount(clist, s_n); if (/* clist->sprites[s_n][(i - 1 < 0) ? (0) : (i - 1)].s_pos_x != 0 && */ s_n + 1 <= 7) - { - ft_get_next_sprite(clist, s_n + 1, c + 1, 0); - } + return (ft_get_next_sprite(clist, s_n + 1, c + 1, 0)); + return (ft_other_next_sprite(clist, s_n)); } void |