finito pipo
This commit is contained in:
Submodule MacroLibX updated: 5a09ebb179...4d640ed70c
5
Makefile
5
Makefile
@ -30,6 +30,7 @@ SRCS = src/utils/mess_error.c \
|
||||
src/parsing/color_utils.c \
|
||||
src/parsing/find_player.c \
|
||||
src/parsing/principal_pars.c \
|
||||
src/parsing/start.c \
|
||||
src/cub3d.c
|
||||
|
||||
OBJS = $(addprefix $(OBJSDIR), $(SRCS:.c=.o))
|
||||
@ -42,9 +43,9 @@ LIB = libft/libft.a \
|
||||
$(NAME): $(OBJS)
|
||||
@make -sj $(nproc) -C $(LIBFT_DIR)
|
||||
@echo "✅ Libft compiled"
|
||||
@make -sj $(nproc) -C $(MACRO_DIR) > /dev/null
|
||||
@make -sj $(nproc) -C $(MACRO_DIR)
|
||||
@echo "✅ MacroLibX compiled"
|
||||
@$(CC) $(FLAGS) $(OBJS) $(LIB) -o $(NAME)
|
||||
@$(CC) $(OBJS) $(LIB) -o $(NAME) $(FLAGS)
|
||||
@echo "✅ Compiled"
|
||||
|
||||
$(OBJSDIR)%.o: %.c
|
||||
|
0
ea_texture.png
Normal file → Executable file
0
ea_texture.png
Normal file → Executable file
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 17:01:05 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:29:55 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 14:30:04 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 21:59:56 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/28 16:52:46 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 18:34:04 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -24,15 +24,14 @@
|
||||
#define NOT_CLOSE "The map isn't closed"
|
||||
#define ERR_PLAYER "Incorrect number of players"
|
||||
#define WRONG_CHAR "Invalid character in the map"
|
||||
#define MISS_MAP "Missing map"
|
||||
|
||||
//for information map
|
||||
|
||||
#define ERR_IMG "Problem with image"
|
||||
#define WRONG_F_IMG "Wrong type of 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"
|
||||
#define ERR_COLOR "The number is not between 0 and 255"
|
||||
#define DUP_COLOR "Impossible to have the same color on the floor and ceiling"
|
||||
#define WRONG_F_RGB "Wrong format RGB"
|
||||
#define INVALID_CHAR "Invalid character in format color"
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/12 12:49:16 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:32:01 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 18:43:16 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -40,7 +40,11 @@ typedef struct s_pars
|
||||
char **map;
|
||||
} t_pars;
|
||||
|
||||
//check_arg.c
|
||||
//start.c
|
||||
t_pars init_pars(void);
|
||||
int basics_check(int ac, char **av, t_pars *pars);
|
||||
|
||||
//check_arg.c
|
||||
int check_err_arg(int ac, char **av);
|
||||
int check_format_file(char *file);
|
||||
|
||||
@ -49,7 +53,6 @@ int detect_info(char **tab, t_pars *pars);
|
||||
|
||||
//check_image.c
|
||||
int assign_img(char *sign, char *path, t_pars *pars);
|
||||
int check_dup_img(t_pars *pars);
|
||||
int check_texture(char *sign, char *path, t_pars *pars);
|
||||
|
||||
//check_map.c
|
||||
@ -65,7 +68,6 @@ int check_format_rgb(char *sign, char **tab, t_pars *pars);
|
||||
int create_argb(int r, int g, int b);
|
||||
char *ft_strndup_color(char *src, int start, int end);
|
||||
int check_char_color(char *tab);
|
||||
int check_dup_color(t_pars *pars);
|
||||
|
||||
//find_player.c
|
||||
int search_letter(char **map, int i, char l);
|
||||
|
16
map.cub
Normal file → Executable file
16
map.cub
Normal file → Executable file
@ -1,9 +1,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NO ./no_texture.png
|
||||
|
||||
|
||||
@ -11,20 +5,17 @@ SO ./so_texture.png
|
||||
|
||||
WE ./we_texture.png
|
||||
EA ./ea_texture.png
|
||||
C 72,48,4
|
||||
F 7,4,46
|
||||
C 255,100,200
|
||||
F 50,0,250
|
||||
|
||||
|
||||
111111
|
||||
1000W1
|
||||
1111111
|
||||
|
||||
|
||||
|
||||
|
||||
11111111111111
|
||||
11
|
||||
1110111
|
||||
11101
|
||||
1111111111111111
|
||||
|
||||
|
||||
@ -37,4 +28,3 @@ F 7,4,46
|
||||
|
||||
|
||||
|
||||
|
||||
|
29
src/cub3d.c
29
src/cub3d.c
@ -6,39 +6,12 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 16:58:27 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:36:29 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 18:45:09 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d.h"
|
||||
|
||||
t_pars init_pars(void)
|
||||
{
|
||||
t_pars new;
|
||||
|
||||
new.f_color = -1;
|
||||
new.c_color = -1;
|
||||
new.color = 0;
|
||||
new.l_player = 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;
|
||||
new.map = NULL;
|
||||
return (new);
|
||||
}
|
||||
|
||||
int basics_check(int ac, char **av, t_pars *pars)
|
||||
{
|
||||
if (check_err_arg(ac, av) == 1)
|
||||
return (1);
|
||||
if (verif_info_file(av[1], pars) == 1)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
t_pars pars;
|
||||
|
21
src/other.c
Normal file
21
src/other.c
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
void f_c_color(void *mlx, void *win, t_pars *pars)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
||||
while (y <= (400 / 2)) //changer 400 par le define
|
||||
{
|
||||
x = 0;
|
||||
while (x <= 800) //changer 800 par le define
|
||||
{
|
||||
mlx_pixel_put(mlx, win, x, y, pars->c_color);
|
||||
mlx_pixel_put(mlx, win, x, 400 - y, pars->f_color); // changer 400 par le define
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/04 21:33:35 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:36:43 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 15:39:53 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -24,10 +24,7 @@ int check_err_arg(int ac, char **av)
|
||||
return (err_mess(ERR_TYPE));
|
||||
fd = open(av[1], O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
close(fd);
|
||||
return (err_mess(EMPTY));
|
||||
}
|
||||
rd = read(fd, buf, 10);
|
||||
close(fd);
|
||||
return (rd);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/16 09:38:32 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:36:52 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 15:51:44 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,25 +6,12 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/19 10:44:07 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:37:04 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 13:39:06 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "parsing.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)
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/16 09:36:07 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:37:25 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 18:10:09 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -68,6 +68,13 @@ int count_precise_char(char *str, char c)
|
||||
|
||||
int check_format_rgb(char *sign, char **tab, t_pars *pars)
|
||||
{
|
||||
static int ct_f;
|
||||
static int ct_c;
|
||||
|
||||
if (ft_strcmp(sign, "F") == 0)
|
||||
ct_f++;
|
||||
if (ft_strcmp(sign, "C") == 0)
|
||||
ct_c++;
|
||||
if (count_tab(tab) > 2)
|
||||
return (err_mess(NOT_FOUND));
|
||||
if (check_char_color(tab[1]) == 1)
|
||||
@ -76,9 +83,11 @@ int check_format_rgb(char *sign, char **tab, t_pars *pars)
|
||||
return (err_mess(WRONG_F_RGB));
|
||||
if (save_color(tab[1], pars, 0, 0) == -1)
|
||||
return (err_mess(ERR_COLOR));
|
||||
if (ct_f > 1 || ct_c > 1)
|
||||
return (err_mess(DUP_ACR));
|
||||
if (ft_strcmp(sign, "F") == 0)
|
||||
pars->f_color = pars->color;
|
||||
else if (ft_strcmp(sign, "C") == 0)
|
||||
if (ft_strcmp(sign, "C") == 0)
|
||||
pars->c_color = pars->color;
|
||||
return (0);
|
||||
}
|
||||
|
@ -6,24 +6,15 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/18 19:44:37 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:37:35 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 17:52:43 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "parsing.h"
|
||||
|
||||
int check_dup_color(t_pars *pars)
|
||||
{
|
||||
if (pars->c_color < 0 || pars->f_color < 0)
|
||||
return (err_mess(NOT_FOUND));
|
||||
if (pars->c_color == pars->f_color)
|
||||
return (err_mess(DUP_COLOR));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int create_argb(int r, int g, int b)
|
||||
{
|
||||
return (r << 16 | g << 8 | b);
|
||||
return (255 << 24 | r << 16 | g << 8 | b);
|
||||
}
|
||||
|
||||
char *ft_strndup_color(char *src, int start, int end)
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/12 12:44:52 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:37:58 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 18:35:52 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -44,6 +44,9 @@ int check_info(char **file, t_pars *pars)
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (pars->f_color == 0 || pars->c_color == 0 || pars->ea_png == NULL || \
|
||||
pars->no_png == NULL || pars->so_png == NULL || pars->we_png == NULL)
|
||||
return (err_mess(NOT_FOUND));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -54,8 +57,7 @@ int verif_info_file(char *av, t_pars *pars)
|
||||
map = parse_file(av, 0, 1);
|
||||
if (map == NULL)
|
||||
return (err_mess(CRASH));
|
||||
if (check_info(map, pars) == 1 || check_dup_img(pars) == 1 || \
|
||||
check_dup_color(pars) == 1 || all_skip(map, pars) == 1)
|
||||
if (check_info(map, pars) == 1 || all_skip(map, pars) == 1)
|
||||
{
|
||||
free_tab(map);
|
||||
return (1);
|
||||
@ -66,6 +68,8 @@ int verif_info_file(char *av, t_pars *pars)
|
||||
|
||||
int verif_all_map(char **map, t_pars *pars)
|
||||
{
|
||||
if (longest_line(map) == 1)
|
||||
return (1);
|
||||
pars->map = alloc_map(map, longest_line(map));
|
||||
if (pars->map == NULL)
|
||||
return (err_mess(CRASH));
|
||||
|
40
src/parsing/start.c
Normal file
40
src/parsing/start.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* start.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/05 18:42:05 by madumerg #+# #+# */
|
||||
/* Updated: 2024/10/05 18:44:40 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "parsing.h"
|
||||
|
||||
t_pars init_pars(void)
|
||||
{
|
||||
t_pars new;
|
||||
|
||||
new.f_color = -1;
|
||||
new.c_color = -1;
|
||||
new.color = 0;
|
||||
new.l_player = 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;
|
||||
new.map = NULL;
|
||||
return (new);
|
||||
}
|
||||
|
||||
int basics_check(int ac, char **av, t_pars *pars)
|
||||
{
|
||||
if (check_err_arg(ac, av) == 1)
|
||||
return (1);
|
||||
if (verif_info_file(av[1], pars) == 1)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/28 15:40:12 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:35:35 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 18:49:41 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/20 09:57:13 by madumerg #+# #+# */
|
||||
/* Updated: 2024/09/29 20:36:00 by madumerg ### ########.fr */
|
||||
/* Updated: 2024/10/05 18:33:01 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -47,6 +47,8 @@ int longest_line(char **line)
|
||||
int actual;
|
||||
|
||||
stock = ft_strlen(line[0]);
|
||||
if (stock == 0)
|
||||
return (err_mess(MISS_MAP));
|
||||
i = 1;
|
||||
actual = 0;
|
||||
while (line[i])
|
||||
|
Reference in New Issue
Block a user