add textures and more fluidity
This commit is contained in:
commit
6db01fbcaa
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/02/13 16:30:59 by apommier #+# #+# */
|
||||
/* Updated: 2022/06/13 23:22:21 by apommier ### ########.fr */
|
||||
/* Updated: 2022/06/14 01:04:15 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -95,6 +95,7 @@ typedef struct s_data {
|
||||
char **double_map;
|
||||
map_info map;
|
||||
player player;
|
||||
int err;
|
||||
} t_data;
|
||||
|
||||
char *transform_map(char **double_map, t_data *img);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/06/11 01:00:17 by apommier #+# #+# */
|
||||
/* Updated: 2022/06/13 20:50:12 by apommier ### ########.fr */
|
||||
/* Updated: 2022/06/14 01:04:04 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/05/10 17:54:25 by sadjigui #+# #+# */
|
||||
/* Updated: 2022/06/13 20:51:12 by apommier ### ########.fr */
|
||||
/* Updated: 2022/06/14 01:03:43 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -90,7 +90,7 @@ int reverse_comp(char *s1, char *s2)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void inter_map(char **split, char **tmp)
|
||||
void inter_map(char **split, char **tmp, t_data *img)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
@ -101,7 +101,12 @@ void inter_map(char **split, char **tmp)
|
||||
j = 0;
|
||||
while(split[i][j])
|
||||
{
|
||||
if (ft_isalnum(split[i][j]))
|
||||
if (split[i][j] == '3')
|
||||
{
|
||||
img->map.error = -1;
|
||||
printf("%s %d\n", "-------------------------------------------", img->map.error);
|
||||
}
|
||||
else if (split[i][j] != ' ')
|
||||
tmp[i + 1][j + 1] = split[i][j];
|
||||
j++;
|
||||
}
|
||||
@ -176,7 +181,7 @@ void check_border(char **tab, t_data *img)
|
||||
j = 0;
|
||||
while (tab[i][j])
|
||||
{
|
||||
if (tab[i][j] == '0')
|
||||
if (tab[i][j] == '0' || tab[i][j] == 'W' || tab[i][j] == 'N' || tab[i][j] == 'S' || tab[i][j] == 'E')
|
||||
close_or_not(tab, i, j, img);
|
||||
j++;
|
||||
}
|
||||
@ -206,14 +211,53 @@ void check_zero_one(char **split, t_data *img)
|
||||
i++;
|
||||
}
|
||||
tmp[i] = NULL;
|
||||
inter_map(split, tmp);
|
||||
inter_map(split, tmp, img);
|
||||
if (img->map.error == -1)
|
||||
return;
|
||||
check_border(tmp, img);
|
||||
check_inner(tmp, img);
|
||||
free_tab(tmp);
|
||||
}
|
||||
|
||||
// typedef struct s_global
|
||||
// {
|
||||
// int err;
|
||||
// } t_global;
|
||||
|
||||
int is_in_charset(char c, char *charset)
|
||||
{
|
||||
while (*charset)
|
||||
{
|
||||
if (c == *charset)
|
||||
return (1);
|
||||
charset++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int detect_map_line(char *line)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (!line)
|
||||
return (0);
|
||||
if (*line == '\0')
|
||||
return (0);
|
||||
while (line[i])
|
||||
{
|
||||
if (is_in_charset(line[i], " 01NSEW\n") == 0)
|
||||
return (0);
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
char **isafile(char **av, t_data *img)
|
||||
{
|
||||
// t_global g;
|
||||
img->err = 0;
|
||||
|
||||
int fd;
|
||||
char *line;
|
||||
char *str;
|
||||
@ -227,6 +271,11 @@ char **isafile(char **av, t_data *img)
|
||||
ft_exit("Error: File doesn't exist\n");
|
||||
while ((line = get_next_line(fd)) != NULL)
|
||||
{
|
||||
if (line[0] != '\n' && img->err == 0)
|
||||
if (detect_map_line(line))
|
||||
img->err = 1;
|
||||
if (line[0] == '\n' && img->err == 1)
|
||||
img->err = 2;
|
||||
tmp = ft_strjoin(str, line);
|
||||
if (str != NULL)
|
||||
free(str);
|
||||
@ -235,11 +284,15 @@ char **isafile(char **av, t_data *img)
|
||||
free(line);
|
||||
line = NULL;
|
||||
}
|
||||
split = ft_split(str, '\n');
|
||||
//printf("this is it\n");
|
||||
//print_double_fd(split, 1);
|
||||
free(line);
|
||||
if (img->err == 2)
|
||||
{
|
||||
// free(line);
|
||||
free(str);
|
||||
ft_exit("Error\nBad texture file\n");
|
||||
}
|
||||
split = ft_split(str, '\n');
|
||||
free(str);
|
||||
free(line);
|
||||
close(fd);
|
||||
int pass = 0;
|
||||
pass = check_texture_color(split, img);
|
||||
@ -266,6 +319,7 @@ int check_map(char **av, t_data *img)
|
||||
img->map.max = img->map.x;
|
||||
else
|
||||
img->map.max = img->map.y;
|
||||
printf("----------------- d = %d", img->map.error);
|
||||
|
||||
if (img->map.error != 0)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user