sixty_percent
This commit is contained in:
2
Makefile
2
Makefile
@ -20,6 +20,8 @@ SRCS = src/utils/mess_error.c \
|
||||
src/utils/parse_utils.c \
|
||||
src/parsing/check_map.c \
|
||||
src/parsing/check_arg.c \
|
||||
src/parsing/check_id_text.c \
|
||||
src/parsing/check_rgb.c \
|
||||
src/parsing/principal_pars.c \
|
||||
src/cub3d.c
|
||||
|
||||
|
0
ea_texture.png
Normal file
0
ea_texture.png
Normal file
@ -6,14 +6,15 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 17:01:05 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/12 12:54:48 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/09/15 20:43:25 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CUB3D_H
|
||||
# define CUB3D_H
|
||||
|
||||
# include "../libft/includes/libft.h"
|
||||
# include "libft.h"
|
||||
# include "ft_printf.h"
|
||||
# include "mess_err.h"
|
||||
# include <stdlib.h>
|
||||
# include <math.h>
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 21:59:56 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/11 14:18:39 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/09/16 12:18:42 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -23,3 +23,8 @@
|
||||
#define WRONG_CHAR "Invalid character in the map"
|
||||
|
||||
//for permission
|
||||
|
||||
#define ERR_IMG "Problem with image"
|
||||
#define DUP_ACR "There is a duplicate acronym"
|
||||
#define DUP_IMG "There is a duplicate image"
|
||||
#define NOT_FOUND "Information searched is not complete"
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/12 12:49:16 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/12 16:58:29 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/09/16 14:23:15 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -24,12 +24,21 @@ typedef struct s_pars
|
||||
int f_color;
|
||||
int c_color;
|
||||
t_coord coor;
|
||||
char *no_png;
|
||||
char *so_png;
|
||||
char *we_png;
|
||||
char *ea_png;
|
||||
} t_pars;
|
||||
|
||||
//check_arg.c
|
||||
int check_err_arg(int ac, char **av);
|
||||
int check_format_file(char *file);
|
||||
|
||||
//check_id_text.c
|
||||
int check_texture(char *sign, char *path, t_pars *pars);
|
||||
int detect_info(char **tab, t_pars *pars);
|
||||
int check_dup_img(t_pars *pars);
|
||||
|
||||
//check_map.c
|
||||
int err_not_close(char after, char before, char down, char up);
|
||||
int actual_char(char actual);
|
||||
@ -37,8 +46,11 @@ int check_map_close(char **map);
|
||||
int count_player(char **map);
|
||||
int check_char_map(char **map);
|
||||
|
||||
//check_rgb.c
|
||||
int check_format_rgb(char **tab);
|
||||
|
||||
//principal_pars.c
|
||||
int verif_info_map(char *av);
|
||||
int verif_info_file(char *av, t_pars *pars);
|
||||
int verif_all_map(char **map);
|
||||
char **parse_map(char *map);
|
||||
|
||||
@ -49,4 +61,6 @@ int err_mess(char *str);
|
||||
char **info_map(char **file);
|
||||
void convert_white_s(char *str);
|
||||
int verif_char(char c);
|
||||
int count_tab(char **tab);
|
||||
int space_line(char *line);
|
||||
#endif
|
||||
|
17
map.cub
17
map.cub
@ -1,14 +1,9 @@
|
||||
NO ./path_to_the_north_texture
|
||||
|
||||
SO ./path_to_the_south_texture
|
||||
|
||||
WE ./path_to_the_west_texture
|
||||
|
||||
EA ./path_to_the_east_texture
|
||||
|
||||
|
||||
F 220,100,0
|
||||
C 225,30,0
|
||||
NO ./no_texture.png
|
||||
SO ./so_texture.png
|
||||
WE ./we_texture.png
|
||||
EA ./ea_texture.png
|
||||
F 220 , 100, 0
|
||||
C 225, 30, 0
|
||||
|
||||
11111
|
||||
1001S1
|
||||
|
0
no_texture.png
Normal file
0
no_texture.png
Normal file
0
so_texture.png
Normal file
0
so_texture.png
Normal file
25
src/cub3d.c
25
src/cub3d.c
@ -6,25 +6,24 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 16:58:27 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/12 16:56:30 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/09/16 13:54:52 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d.h"
|
||||
#include "libft.h"
|
||||
#include "parsing.h"
|
||||
|
||||
t_pars init_pars(void)
|
||||
{
|
||||
t_pars new;
|
||||
|
||||
new = ft_calloc(sizeof(t_pars));
|
||||
if (!new)
|
||||
return (NULL);
|
||||
new->f_color = 0;
|
||||
new->c_color = 0;
|
||||
new->coor->x = 0;
|
||||
new->coor->y = 0
|
||||
new.f_color = 0;
|
||||
new.c_color = 0;
|
||||
new.coor.x = 0;
|
||||
new.coor.y = 0;
|
||||
new.no_png = NULL;
|
||||
new.so_png = NULL;
|
||||
new.we_png = NULL;
|
||||
new.ea_png = NULL;
|
||||
return (new);
|
||||
}
|
||||
|
||||
@ -32,10 +31,10 @@ int main(int ac, char **av)
|
||||
{
|
||||
t_pars pars;
|
||||
|
||||
pars = init_pars(void);
|
||||
pars = init_pars();
|
||||
if (check_err_arg(ac, av) == 1)
|
||||
return (1);
|
||||
if (verif_info_map(av[1], &pars) == 1)
|
||||
return (1);
|
||||
if (verif_info_file(av[1], &pars) == 1)
|
||||
printf("main\n");
|
||||
return (0);
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* check_id_text.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/16 09:38:32 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/16 14:38:35 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d.h"
|
||||
|
||||
int check_dup_img(t_pars *pars)
|
||||
{
|
||||
if (!pars->no_png || !pars->so_png || !pars->we_png || !pars->ea_png)
|
||||
return (err_mess(NOT_FOUND));
|
||||
if (ft_strcmp(pars->no_png, pars->so_png) == 0 || \
|
||||
ft_strcmp(pars->no_png, pars->we_png) == 0 || \
|
||||
ft_strcmp(pars->no_png, pars->ea_png) == 0 || \
|
||||
ft_strcmp(pars->so_png, pars->we_png) == 0 || \
|
||||
ft_strcmp(pars->we_png, pars->ea_png) == 0)
|
||||
return (err_mess(DUP_IMG));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int assign_img_two(char *sign, char *path, t_pars *pars)
|
||||
{
|
||||
if (ft_strcmp("WE", sign) == 0)
|
||||
{
|
||||
if (pars->we_png == NULL)
|
||||
pars->we_png = path;
|
||||
else
|
||||
return (err_mess(DUP_ACR));
|
||||
}
|
||||
else if (ft_strcmp("EA", sign) == 0)
|
||||
{
|
||||
if (pars->ea_png == NULL)
|
||||
pars->ea_png = path;
|
||||
else
|
||||
return (err_mess(DUP_ACR));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int assign_img(char *sign, char *path, t_pars *pars)
|
||||
{
|
||||
if (ft_strcmp("NO", sign) == 0)
|
||||
{
|
||||
if (pars->no_png == NULL)
|
||||
pars->no_png = path;
|
||||
else
|
||||
return (err_mess(DUP_ACR));
|
||||
}
|
||||
else if (ft_strcmp("SO", sign) == 0)
|
||||
{
|
||||
if (pars->so_png == NULL)
|
||||
pars->so_png = path;
|
||||
else
|
||||
return (err_mess(DUP_ACR));
|
||||
}
|
||||
if (assign_img_two(sign, path, pars) == 1)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int check_texture(char *sign, char *path, t_pars *pars)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = -1;
|
||||
fd = open(path, O_RDONLY, 0644);
|
||||
if (fd < 0)
|
||||
return (err_mess(ERR_IMG));
|
||||
if (assign_img(sign, path, pars) == 1)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int detect_info(char **tab, t_pars *pars)
|
||||
{
|
||||
if (ft_strcmp("NO", tab[0]) == 0 && count_tab(tab) == 2)
|
||||
return (check_texture(tab[0], tab[1], pars));
|
||||
else if (ft_strcmp("SO", tab[0]) == 0 && count_tab(tab) == 2)
|
||||
return (check_texture(tab[0], tab[1], pars));
|
||||
else if (ft_strcmp("WE", tab[0]) == 0 && count_tab(tab) == 2)
|
||||
return (check_texture(tab[0], tab[1], pars));
|
||||
else if (ft_strcmp("EA", tab[0]) == 0 && count_tab(tab) == 2)
|
||||
return (check_texture(tab[0], tab[1], pars));
|
||||
else if (ft_strcmp("F", tab[0]) == 0)
|
||||
check_format_rgb(tab);
|
||||
else if (ft_strcmp("C", tab[0]) == 0)
|
||||
check_format_rgb(tab);
|
||||
else
|
||||
return (err_mess(NOT_FOUND));
|
||||
return (0);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* check_rgb.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/16 09:36:07 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/16 14:59:30 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d.h"
|
||||
|
||||
int check_format_rgb(char **tab)
|
||||
{
|
||||
int i = 0;
|
||||
while (tab[i])
|
||||
printf(".%s.\n", tab[i++]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int create_argb(int a, int r, int g, int b)
|
||||
{
|
||||
return (a << 24 | r << 16 | g << 8 | b);
|
||||
}
|
@ -1,6 +1,18 @@
|
||||
// convertir tt les whites spaces en simple espace sur les 6 1ere lignes
|
||||
|
||||
//check si .png
|
||||
WARNIIIIIINNNNNNNNNNNNNGGG TESTER LES MALLOC A NULL
|
||||
|
||||
//faire struct de coor
|
||||
//faire search player
|
||||
utiliser la ft pour couleur
|
||||
|
||||
|
||||
no so
|
||||
no we
|
||||
no ea
|
||||
|
||||
so we
|
||||
so ea
|
||||
|
||||
we ea
|
||||
|
||||
|
@ -6,28 +6,53 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/12 12:44:52 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/12 16:49:20 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/09/16 14:58:26 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d.h"
|
||||
|
||||
int check_info(char **l)
|
||||
int all_data_verif(char **tab, t_pars *pars)
|
||||
{
|
||||
|
||||
if (detect_info(tab, pars) == 1)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int verif_info_map(char *av)
|
||||
int check_info(char **l, t_pars *pars)
|
||||
{
|
||||
char **tab;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
tab = ft_calloc(sizeof(char *), 6);
|
||||
if (!tab)
|
||||
return (1);
|
||||
while (l[i])
|
||||
{
|
||||
tab = ft_split(l[i], ' ');
|
||||
if (all_data_verif(tab, pars) == 1)
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int verif_info_file(char *av, t_pars *pars)
|
||||
{
|
||||
char **map;
|
||||
char **f_part;
|
||||
|
||||
(void)pars;
|
||||
map = parse_map(av);
|
||||
f_part = info_map(map);
|
||||
if (check_info(f_part) == 1)
|
||||
return (1);
|
||||
if (verif_all_map(map) == 1)
|
||||
if (check_info(f_part, pars) == 1)
|
||||
return (1);
|
||||
// if (check_dup_img(pars) == 1)
|
||||
// return (1);
|
||||
// if (verif_all_map(map) == 1)
|
||||
// return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int verif_all_map(char **map)
|
||||
|
@ -6,12 +6,30 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/11 14:20:54 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/12 16:20:31 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/09/16 14:55:36 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d.h"
|
||||
|
||||
int space_line(char *line)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
convert_white_s(line);
|
||||
while (line[i])
|
||||
{
|
||||
if (line[i] == ' ' || (line[i] >= 9 && line[i] <= 13))
|
||||
i++;
|
||||
else
|
||||
break ;
|
||||
}
|
||||
if (line[i] != '\0')
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
char **info_map(char **file)
|
||||
{
|
||||
char **f_part;
|
||||
@ -23,10 +41,15 @@ char **info_map(char **file)
|
||||
f_part = ft_calloc(6, sizeof(char *));
|
||||
if (!f_part)
|
||||
return (NULL);
|
||||
while (i < 6)
|
||||
while (i >= j)
|
||||
{
|
||||
if (j == 6)
|
||||
break ;
|
||||
if (space_line(file[i]) == 1)
|
||||
{
|
||||
f_part[j] = file[i];
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (f_part);
|
||||
@ -52,3 +75,18 @@ int verif_char(char c)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int count_tab(char **tab)
|
||||
{
|
||||
int i;
|
||||
int ct;
|
||||
|
||||
i = 0;
|
||||
ct = 0;
|
||||
while (tab[i])
|
||||
{
|
||||
i++;
|
||||
ct++;
|
||||
}
|
||||
return (ct);
|
||||
}
|
||||
|
0
we_texture.png
Normal file
0
we_texture.png
Normal file
Reference in New Issue
Block a user