15static int get_texture_image(
16 void *mlx,
const char *first_word,
t_texture *texture)
18 const char *next_word;
21 next_word = find_next_word(first_word);
22 if (next_word == NULL)
24 put_error_msg(first_word, EMSG_XPM_FILE);
25 return (EXIT_FAILURE);
27 file = strdup_trimmed_line(next_word);
29 return (EXIT_FAILURE);
30 texture->img_tex.img = (
void *)mlx_xpm_file_to_image(
31 mlx, file, &texture->width, &texture->height);
32 if (texture->img_tex.img == NULL)
34 ft_eprintf(
"%s%s: %s\n", ERR_PROMPT, EMSG_MLX_XPM_TO_IMG, file);
36 return (EXIT_FAILURE);
39 return (EXIT_SUCCESS);
48static void clear_flag_of_texture(
t_parse *parse)
52 clear_flag = ~(BIT_NORTH | BIT_WEST | BIT_EAST | BIT_SOUTH);
53 parse->flag = parse->flag & clear_flag;
56int create_texture_image(
const char *line,
t_parse *parse, t_type_wall type)
61 mlx = parse->game->mlx;
62 texture = parse->game->texture;
63 if (get_texture_image(mlx, line, &texture[type]) != EXIT_SUCCESS)
65 destroy_texture_image(mlx, texture, parse->flag);
66 clear_flag_of_texture(parse);
67 return (EXIT_FAILURE);
69 return (EXIT_SUCCESS);