Archived
1
0

finito pipo

This commit is contained in:
Maelys
2024-10-05 18:59:47 +02:00
parent 6c9d2b3931
commit 9e23c245cd
18 changed files with 105 additions and 89 deletions

View File

@ -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
View 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++;
}
}

View File

@ -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);

View File

@ -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 */
/* */
/* ************************************************************************** */

View File

@ -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)

View File

@ -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);
}

View File

@ -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)

View File

@ -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
View 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);
}

View File

@ -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 */
/* */
/* ************************************************************************** */

View File

@ -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])