Textures file added
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/11/25 19:47:02 by aortigos #+# #+# */
|
/* Created: 2025/11/25 19:47:02 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/11/28 20:13:53 by aortigos ### ########.fr */
|
/* Updated: 2025/12/01 10:03:36 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -36,12 +36,16 @@ void get_x_y_player(t_data *data);
|
|||||||
int check_extension_map(char *file);
|
int check_extension_map(char *file);
|
||||||
int parsing(int ac, char **av, t_data *data);
|
int parsing(int ac, char **av, t_data *data);
|
||||||
|
|
||||||
//frees.c
|
// frees.c
|
||||||
void freetl(char *ture, char *line, int fd);
|
void freetl(char *ture, char *line, int fd);
|
||||||
void free_map(t_data *data);
|
void free_map(t_data *data);
|
||||||
void free_m(t_mlx *mlx);
|
void free_m(t_mlx *mlx);
|
||||||
void freelist(t_turelist **txture);
|
void freelist(t_turelist **txture);
|
||||||
|
|
||||||
|
// textures.c
|
||||||
|
int get_index(char *line, int i);
|
||||||
|
t_turelist *new_texture(char *line);
|
||||||
|
void lst_back_ture(t_turelist **l_ture, t_turelist *new);
|
||||||
|
int lst_ture(t_data *m, t_turelist **l_ture);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
75
src/parsing/textures.c
Normal file
75
src/parsing/textures.c
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* textures.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/12/01 08:48:55 by aortigos #+# #+# */
|
||||||
|
/* Updated: 2025/12/01 10:02:55 by aortigos ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../../includes/cub3d.h"
|
||||||
|
|
||||||
|
int get_index(char *line, int i)
|
||||||
|
{
|
||||||
|
while (ft_isspace(line[i]))
|
||||||
|
i++;
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_turelist *new_texture(char *line)
|
||||||
|
{
|
||||||
|
t_turelist *list;
|
||||||
|
|
||||||
|
list = (t_turelist *)ft_calloc(sizeof(t_turelist), 1);
|
||||||
|
if (!list)
|
||||||
|
return (NULL);
|
||||||
|
while (ft_isspace(*line))
|
||||||
|
line++;
|
||||||
|
if ((!ft_strncmp(line, "NO", 2) || !ft_strncmp(line, "sO", 2))
|
||||||
|
|| !ft_strncmp(line, "WE", 2) || !ft_strncmp(line, "EA", 2))
|
||||||
|
{
|
||||||
|
list->name = ft_substr(line, 0, 2);
|
||||||
|
list->value = ft_substr(line, get_index(line, 2), ft_strlen(line));
|
||||||
|
}
|
||||||
|
else if ((!ft_strncmp(line, "F", 1) || !ft_strncmp(line, "C", 1)))
|
||||||
|
{
|
||||||
|
list->name = ft_substr(line, 0, 1);
|
||||||
|
list->value = ft_substr(line, get_index(line, 1), ft_strlen(line));
|
||||||
|
}
|
||||||
|
list->next = NULL;
|
||||||
|
return (list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lst_back_ture(t_turelist **l_ture, t_turelist *new)
|
||||||
|
{
|
||||||
|
t_turelist *tmp;
|
||||||
|
|
||||||
|
if (!*l_ture)
|
||||||
|
{
|
||||||
|
(*l_ture) = new;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
tmp = *l_ture;
|
||||||
|
while (tmp->next)
|
||||||
|
tmp = tmp->next;
|
||||||
|
tmp->next = new;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lst_ture(t_data *m, t_turelist **l_ture)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
t_turelist *tmp;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (m->ture2d[i])
|
||||||
|
{
|
||||||
|
tmp = new_texture(m->ture2d[i++]);
|
||||||
|
if (!tmp)
|
||||||
|
return (0);
|
||||||
|
lst_back_ture(l_ture, tmp);
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user