42_solong/color.c
Camille Chauvet 5deb78a5cf kekw
2023-01-10 19:04:46 +01:00

57 lines
2.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* color.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/08 15:56:19 by cchauvet #+# #+# */
/* Updated: 2023/01/10 18:04:00 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
static int ft_textures_set(t_data *data, char **colors)
{
t_square square;
square.size = CASE_SIZE;
square.color = colors[ft_random_generator(0, 100)];
data->ecolor = name_generator(square);
square.color = colors[ft_random_generator(0, 100)];
data->pcolor = name_generator(square);
square.color = colors[ft_random_generator(0, 100)];
data->wcolor = name_generator(square);
square.color = colors[ft_random_generator(0, 100)];
data->ccolor = name_generator(square);
square.color = colors[ft_random_generator(0, 100)];
square.size = WINDOW_SIZE;
square.color = colors[ft_random_generator(0, 100)];
data->bcolor = name_generator(square);
if (data->bcolor == NULL || data->wcolor == NULL || data->pcolor == NULL
|| data->ecolor == NULL || data->ccolor == NULL)
{
ft_printf("Memory error");
ft_freer_ultimate(5, data->wcolor, data->ecolor, data->bcolor);
ft_freer_ultimate(2, data->pcolor, data->ccolor);
return (1);
}
return (0);
}
int ft_color_changer(t_data *data)
{
char **colors;
colors = ft_split(COLORS, '|');
if (colors == NULL)
{
ft_printf("Memory error");
return (1);
}
ft_textures_set(data, colors);
ft_freer_tab_ultimate(1, colors);
return (0);
}