/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_init_sprites.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:28:53 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:28:53 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include #include /* ** cl->sprite[] index summary ** -------------------------- ** 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 ** 13: enemy - tlist[23] | ** '- - - - - - - tlist[24] | ** '- - - - - - - tlist[25] | ** '- - - - - - - tlist[26] - 32 */ int8_t ft_init_sprites(t_sprite ***sprites) { int8_t i; if (!(*sprites = (t_sprite**)ft_calloc(FT_TOTAL_SPRT, sizeof(t_sprite*)))) return (-1); i = -1; while (++i < 8) { if (!(*((*sprites) + i) = (t_sprite*)ft_calloc(4096, sizeof(t_sprite)))) return (-1); } if (!(*((*sprites) + 8) = (t_sprite*)ft_calloc(512, sizeof(t_sprite)))) return (-1); if (!(*((*sprites) + 9) = (t_sprite*)ft_calloc(64, sizeof(t_sprite)))) return (-1); i = 9; while (++i < 13) { if (!(*((*sprites) + i) = (t_sprite*)ft_calloc(4, sizeof(t_sprite)))) return (-1); } if (!(*((*sprites) + 13) = (t_sprite*)ft_calloc(32, sizeof(t_sprite)))) return (-1); return (0); }