42_solong/asset.c

45 lines
1.5 KiB
C
Raw Normal View History

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