42_solong/asset.c
Camille Chauvet eb54b7bc0f kekw
2023-01-11 19:10:28 +01:00

45 lines
1.5 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* asset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/06 14:23:00 by cchauvet #+# #+# */
/* Updated: 2023/01/11 19:08:46 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
int ft_gen_assets(t_data *data)
{
char **colors;
t_square square;
size_t i;
int y;
char *name;
colors = ft_split(COLORS, '|');
if (colors == NULL)
return (1);
i = 0;
while (i < NB_COLORS)
{
square.color = colors[i];
square.size = CASE_SIZE;
name = ft_xpm_gen_file(square);
data->assets[i] = mlx_xpm_file_to_image(data->mlx,
name, &y, &y);
free(name);
square.size = WINDOW_SIZE;
name = ft_xpm_gen_file(square);
data->assets[i + NB_COLORS] = mlx_xpm_file_to_image(data->mlx,
name, &y, &y);
free(name);
i++;
}
ft_freer_tab_ultimate(1, colors);
return (0);
}