/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* draw.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cchauvet mlx, data->window, img, x, y); } static void *ft_char2img(t_data *data, char c) { if (c == 'C') return (data->assets[0]); if (c == '1') return (data->assets[1]); if (c == 'E') return (data->assets[2]); if (c == 'P') return (data->assets[3]); return (NULL); } int ft_draw_map(t_data *data) { ssize_t tab[2]; char **patern; void *img; ft_fill_pos(data->map); patern = ft_get_player_map(*data->map); if (patern == NULL) return (1); ft_draw_img(data, data->assets[NB_COLORS], 0, 0); tab[1] = -1; while (patern[++tab[1]] != NULL) { tab[0] = -1; while (patern[tab[1]][++tab[0]] != '\0') { img = ft_char2img(data, patern[tab[1]][tab[0]]); if (img != NULL) ft_draw_img(data, img, tab[0] * CASE_SIZE, tab[1] * CASE_SIZE); } } ft_freer_tab_ultimate(1, patern); return (0); }