add textures and more fluidity
This commit is contained in:
commit
6db01fbcaa
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/02/13 16:30:59 by apommier #+# #+# */
|
/* 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;
|
char **double_map;
|
||||||
map_info map;
|
map_info map;
|
||||||
player player;
|
player player;
|
||||||
|
int err;
|
||||||
} t_data;
|
} t_data;
|
||||||
|
|
||||||
char *transform_map(char **double_map, t_data *img);
|
char *transform_map(char **double_map, t_data *img);
|
||||||
@ -114,4 +115,4 @@ void ft_error(char *error_msg);
|
|||||||
void print_player(player player, t_data *img);
|
void print_player(player player, t_data *img);
|
||||||
void print_map(map_info map, t_data *img);
|
void print_map(map_info map, t_data *img);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/06/11 01:00:17 by apommier #+# #+# */
|
/* 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ char *transform_map(char **double_map, t_data *img)
|
|||||||
//printf("index= %d\n", index);
|
//printf("index= %d\n", index);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
img->map.simple_map = map;
|
img->map.simple_map = map;
|
||||||
//printf("map = -%s-\n", map);
|
//printf("map = -%s-\n", map);
|
||||||
@ -139,4 +139,4 @@ int check_texture_color(char **tab, t_data *img)
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return (next);
|
return (next);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/05/10 17:54:25 by sadjigui #+# #+# */
|
/* 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);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void inter_map(char **split, char **tmp)
|
void inter_map(char **split, char **tmp, t_data *img)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@ -101,7 +101,12 @@ void inter_map(char **split, char **tmp)
|
|||||||
j = 0;
|
j = 0;
|
||||||
while(split[i][j])
|
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];
|
tmp[i + 1][j + 1] = split[i][j];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@ -176,7 +181,7 @@ void check_border(char **tab, t_data *img)
|
|||||||
j = 0;
|
j = 0;
|
||||||
while (tab[i][j])
|
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);
|
close_or_not(tab, i, j, img);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@ -206,14 +211,53 @@ void check_zero_one(char **split, t_data *img)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
tmp[i] = NULL;
|
tmp[i] = NULL;
|
||||||
inter_map(split, tmp);
|
inter_map(split, tmp, img);
|
||||||
|
if (img->map.error == -1)
|
||||||
|
return;
|
||||||
check_border(tmp, img);
|
check_border(tmp, img);
|
||||||
check_inner(tmp, img);
|
check_inner(tmp, img);
|
||||||
free_tab(tmp);
|
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)
|
char **isafile(char **av, t_data *img)
|
||||||
{
|
{
|
||||||
|
// t_global g;
|
||||||
|
img->err = 0;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
char *line;
|
char *line;
|
||||||
char *str;
|
char *str;
|
||||||
@ -227,6 +271,11 @@ char **isafile(char **av, t_data *img)
|
|||||||
ft_exit("Error: File doesn't exist\n");
|
ft_exit("Error: File doesn't exist\n");
|
||||||
while ((line = get_next_line(fd)) != NULL)
|
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);
|
tmp = ft_strjoin(str, line);
|
||||||
if (str != NULL)
|
if (str != NULL)
|
||||||
free(str);
|
free(str);
|
||||||
@ -235,11 +284,15 @@ char **isafile(char **av, t_data *img)
|
|||||||
free(line);
|
free(line);
|
||||||
line = NULL;
|
line = NULL;
|
||||||
}
|
}
|
||||||
|
if (img->err == 2)
|
||||||
|
{
|
||||||
|
// free(line);
|
||||||
|
free(str);
|
||||||
|
ft_exit("Error\nBad texture file\n");
|
||||||
|
}
|
||||||
split = ft_split(str, '\n');
|
split = ft_split(str, '\n');
|
||||||
//printf("this is it\n");
|
|
||||||
//print_double_fd(split, 1);
|
|
||||||
free(line);
|
|
||||||
free(str);
|
free(str);
|
||||||
|
free(line);
|
||||||
close(fd);
|
close(fd);
|
||||||
int pass = 0;
|
int pass = 0;
|
||||||
pass = check_texture_color(split, img);
|
pass = check_texture_color(split, img);
|
||||||
@ -266,7 +319,8 @@ int check_map(char **av, t_data *img)
|
|||||||
img->map.max = img->map.x;
|
img->map.max = img->map.x;
|
||||||
else
|
else
|
||||||
img->map.max = img->map.y;
|
img->map.max = img->map.y;
|
||||||
|
printf("----------------- d = %d", img->map.error);
|
||||||
|
|
||||||
if (img->map.error != 0)
|
if (img->map.error != 0)
|
||||||
{
|
{
|
||||||
error_msg(img);
|
error_msg(img);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user