kekw
This commit is contained in:
parent
975e0c2ef5
commit
d7256c47a5
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
|||||||
SRCS = draw.c main.c map.c shape.c xpm.c
|
SRCS = asset.c draw.c main.c map.c parsing.c shape.c xpm.c
|
||||||
|
|
||||||
OBJ = ${SRCS:.c=.o}
|
OBJ = ${SRCS:.c=.o}
|
||||||
|
|
||||||
|
74
asset.c
Normal file
74
asset.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* asset.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/01/06 14:23:00 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/01/06 18:20:19 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "solong.h"
|
||||||
|
|
||||||
|
static void ft_freer(char **tab)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
if (tab == NULL)
|
||||||
|
return ;
|
||||||
|
while (tab[i] != NULL)
|
||||||
|
{
|
||||||
|
free(tab[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
free(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ft_freer_utimate(size_t len, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
va_start(va, len);
|
||||||
|
while (i < len)
|
||||||
|
{
|
||||||
|
ft_freer(va_arg(va, char **));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_gen_assets(void)
|
||||||
|
{
|
||||||
|
char **colors;
|
||||||
|
char **shapes;
|
||||||
|
size_t tab[2];
|
||||||
|
t_shape shape;
|
||||||
|
|
||||||
|
colors = ft_split(COLORS, '|');
|
||||||
|
shapes = ft_split(SHAPES, '|');
|
||||||
|
if (shapes == NULL && colors == NULL)
|
||||||
|
{
|
||||||
|
ft_freer_utimate(2, shapes, colors);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
tab[0] = -1;
|
||||||
|
while (colors[++tab[0]] != NULL)
|
||||||
|
{
|
||||||
|
tab[1] = -1;
|
||||||
|
while (shapes[++tab[1]] != NULL)
|
||||||
|
{
|
||||||
|
shape.color = colors[tab[0]];
|
||||||
|
shape.bcolor = BACKGROUND_COLOR;
|
||||||
|
shape.shape = shapes[tab[1]];
|
||||||
|
shape.size = CASE_SIZE;
|
||||||
|
free(ft_xpm_gen_file(shape));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ft_freer_utimate(2, shapes, colors);
|
||||||
|
return (0);
|
||||||
|
}
|
34
draw.c
34
draw.c
@ -6,22 +6,42 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/12/13 15:49:23 by cchauvet #+# #+# */
|
/* Created: 2022/12/13 15:49:23 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/04 19:05:04 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/06 18:49:39 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "solong.h"
|
#include "solong.h"
|
||||||
|
|
||||||
void ft_draw_xpm(void *mlx, void *window, char *file, size_t *cord)
|
void ft_draw_xpm(void *mlx, void *window, char *img_path, size_t *cord)
|
||||||
{
|
{
|
||||||
char *img_path;
|
|
||||||
void *img;
|
|
||||||
int bozo;
|
int bozo;
|
||||||
|
void *img;
|
||||||
|
|
||||||
img_path = ft_strmerger(2, XPM_PATH, file);
|
|
||||||
if (img_path == NULL)
|
|
||||||
return ;
|
|
||||||
img = mlx_xpm_file_to_image(mlx, img_path, &bozo, &bozo);
|
img = mlx_xpm_file_to_image(mlx, img_path, &bozo, &bozo);
|
||||||
mlx_put_image_to_window(mlx, window, img, cord[0], cord[1]);
|
mlx_put_image_to_window(mlx, window, img, cord[0], cord[1]);
|
||||||
mlx_destroy_image(mlx, img);
|
mlx_destroy_image(mlx, img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ft_draw_map(void *mlx, void *window, t_map map)
|
||||||
|
{
|
||||||
|
size_t x;
|
||||||
|
size_t y;
|
||||||
|
|
||||||
|
map = ft_getmap(path);
|
||||||
|
if (map == NULL)
|
||||||
|
return (0);
|
||||||
|
if (ft_map_is_correct(map))
|
||||||
|
{
|
||||||
|
free(map);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
y = 0;
|
||||||
|
while (y < 0)
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
while (x < 0)
|
||||||
|
x++;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
0
la fonction map bozo
Normal file
0
la fonction map bozo
Normal file
@ -1,4 +1,4 @@
|
|||||||
:# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
# #
|
# #
|
||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# Makefile :+: :+: :+: #
|
# Makefile :+: :+: :+: #
|
||||||
@ -6,13 +6,13 @@
|
|||||||
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
|
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
|
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
|
||||||
# Updated: 2023/01/05 19:00:54 by cchauvet ### ########.fr #
|
# Updated: 2023/01/05 20:32:04 by cchauvet ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
CC = clang
|
CC = clang
|
||||||
|
|
||||||
SRCS = draw.c main.c map.c shape.c xpm.c
|
SRCS = ft_strchri.c ft_strcmp.c ft_strfjoin.c ft_strmerger.c ft_strndup.c ft_tabrealloc.c ft_is_in.c
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
BIN
libftx/extra/extra.a
Normal file
BIN
libftx/extra/extra.a
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */
|
/* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/05 18:59:25 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/05 20:31:50 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
char *ft_strfjoin(char *s1, char *s2);
|
char *ft_strfjoin(char *s1, char *s2);
|
||||||
char *ft_strmerger(size_t arg_len, ...);
|
char *ft_strmerger(size_t arg_len, ...);
|
||||||
|
int ft_is_in(char *str, char c);
|
||||||
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
|
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
|
||||||
|
char *ft_strndup(char *src, size_t n);
|
||||||
|
ssize_t ft_strchri(char *str, char c);
|
||||||
int ft_strcmp(char *s1, char *s2);
|
int ft_strcmp(char *s1, char *s2);
|
||||||
#endif
|
#endif
|
||||||
|
26
libftx/extra/ft_is_in.c
Normal file
26
libftx/extra/ft_is_in.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_is_in.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/01/05 20:29:53 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/01/05 20:31:20 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "extra.h"
|
||||||
|
|
||||||
|
int ft_is_in(char *str, char c)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0')
|
||||||
|
{
|
||||||
|
if (str[i] == c)
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
BIN
libftx/extra/ft_is_in.o
Normal file
BIN
libftx/extra/ft_is_in.o
Normal file
Binary file not shown.
28
libftx/extra/ft_strchri.c
Normal file
28
libftx/extra/ft_strchri.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strchri.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/01/05 19:22:58 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/01/05 19:23:13 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "extra.h"
|
||||||
|
|
||||||
|
ssize_t ft_strchri(char *str, char c)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
return (-1);
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != c && str[i] != '\0')
|
||||||
|
i++;
|
||||||
|
if (str[i] == '\0')
|
||||||
|
return (-1);
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
|
BIN
libftx/extra/ft_strchri.o
Normal file
BIN
libftx/extra/ft_strchri.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strcmp.o
Normal file
BIN
libftx/extra/ft_strcmp.o
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/01/04 14:06:04 by cchauvet #+# #+# */
|
/* Created: 2023/01/04 14:06:04 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/04 14:17:40 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/05 19:38:35 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,17 +14,20 @@
|
|||||||
|
|
||||||
char *ft_strfjoin(char *s1, char *s2)
|
char *ft_strfjoin(char *s1, char *s2)
|
||||||
{
|
{
|
||||||
size_t i;
|
ssize_t i;
|
||||||
size_t y;
|
ssize_t y;
|
||||||
char *out;
|
char *out;
|
||||||
|
|
||||||
out = malloc((ft_strlen(s1) + ft_strlen(s2) + 1) * sizeof(char));
|
out = malloc((ft_strlen(s1) + ft_strlen(s2) + 1) * sizeof(char));
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
i = -1;
|
i = 0;
|
||||||
if (s1 != NULL)
|
if (s1 != NULL)
|
||||||
while (s1[++i] != '\0')
|
while (s1[i] != '\0')
|
||||||
|
{
|
||||||
out[i] = s1[i];
|
out[i] = s1[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
free(s1);
|
free(s1);
|
||||||
y = -1;
|
y = -1;
|
||||||
if (s2 != NULL)
|
if (s2 != NULL)
|
||||||
|
BIN
libftx/extra/ft_strfjoin.o
Normal file
BIN
libftx/extra/ft_strfjoin.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strmerger.o
Normal file
BIN
libftx/extra/ft_strmerger.o
Normal file
Binary file not shown.
@ -1,64 +1,16 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* get_next_line_utils.c :+: :+: :+: */
|
/* ft_strndup.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/26 00:55:44 by cchauvet #+# #+# */
|
/* Created: 2022/10/26 00:55:44 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/05 13:06:37 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/05 19:27:03 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "get_next_line.h"
|
#include "extra.h"
|
||||||
|
|
||||||
void *ft_calloc(size_t nmemb, size_t size)
|
|
||||||
{
|
|
||||||
char *tab;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (nmemb == 0 || size * nmemb / nmemb != size)
|
|
||||||
return (NULL);
|
|
||||||
tab = malloc(nmemb * size);
|
|
||||||
if (tab == NULL)
|
|
||||||
return (NULL);
|
|
||||||
i = 0;
|
|
||||||
while (i < size * nmemb)
|
|
||||||
{
|
|
||||||
tab[i] = 0;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return ((void *) tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *ft_strfjoin(char *s1, char *s2)
|
|
||||||
{
|
|
||||||
ssize_t i;
|
|
||||||
ssize_t j;
|
|
||||||
char *out;
|
|
||||||
|
|
||||||
out = ft_calloc((ft_strlen(s1) + ft_strlen(s2) + 1), sizeof(char));
|
|
||||||
if (out == NULL)
|
|
||||||
return (NULL);
|
|
||||||
i = 0;
|
|
||||||
if (s1 != NULL)
|
|
||||||
{
|
|
||||||
while (s1[i] != '\0')
|
|
||||||
{
|
|
||||||
out[i] = s1[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(s1);
|
|
||||||
j = -1;
|
|
||||||
if (s2 != NULL)
|
|
||||||
{
|
|
||||||
while (s2[++j] != '\0')
|
|
||||||
out[i + j] = s2[j];
|
|
||||||
}
|
|
||||||
free(s2);
|
|
||||||
return (out);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *ft_strndup(char *src, size_t n)
|
char *ft_strndup(char *src, size_t n)
|
||||||
{
|
{
|
||||||
@ -78,17 +30,3 @@ char *ft_strndup(char *src, size_t n)
|
|||||||
}
|
}
|
||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t ft_strchri(char *str, char c)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (str == NULL)
|
|
||||||
return (-1);
|
|
||||||
i = 0;
|
|
||||||
while (str[i] != c && str[i] != '\0')
|
|
||||||
i++;
|
|
||||||
if (str[i] == '\0')
|
|
||||||
return (-1);
|
|
||||||
return (i);
|
|
||||||
}
|
|
BIN
libftx/extra/ft_strndup.o
Normal file
BIN
libftx/extra/ft_strndup.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_tabrealloc.o
Normal file
BIN
libftx/extra/ft_tabrealloc.o
Normal file
Binary file not shown.
@ -6,11 +6,11 @@
|
|||||||
# By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ #
|
# By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2022/12/14 15:49:18 by cchauvet #+# #+# #
|
# Created: 2022/12/14 15:49:18 by cchauvet #+# #+# #
|
||||||
# Updated: 2023/01/05 17:44:06 by cchauvet ### ########.fr #
|
# Updated: 2023/01/05 19:22:40 by cchauvet ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
SRCS = get_next_line.c get_next_line_utils.c
|
SRCS = get_next_line.c
|
||||||
|
|
||||||
OBJS = ${SRCS:.c=.o}
|
OBJS = ${SRCS:.c=.o}
|
||||||
|
|
||||||
|
BIN
libftx/gnl/get_next_line.a
Normal file
BIN
libftx/gnl/get_next_line.a
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/11/14 15:38:06 by cchauvet #+# #+# */
|
/* Created: 2022/11/14 15:38:06 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/05 13:06:19 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/05 19:27:45 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -18,10 +18,6 @@
|
|||||||
# define BUFFER_SIZE 42
|
# define BUFFER_SIZE 42
|
||||||
# endif
|
# endif
|
||||||
# include "../libft/libft.h"
|
# include "../libft/libft.h"
|
||||||
void *ft_calloc(size_t nmemb, size_t size);
|
# include "../extra/extra.h"
|
||||||
void *ft_realloc(void *ptr, size_t size);
|
|
||||||
char *ft_strfjoin(char *dst, char *src);
|
|
||||||
char *ft_strndup(char *src, size_t n);
|
|
||||||
ssize_t ft_strchri(char *str, char c);
|
|
||||||
char *get_next_line(int fd);
|
char *get_next_line(int fd);
|
||||||
#endif
|
#endif
|
||||||
|
BIN
libftx/gnl/get_next_line.o
Normal file
BIN
libftx/gnl/get_next_line.o
Normal file
Binary file not shown.
BIN
libftx/gnl/get_next_line_utils.o
Normal file
BIN
libftx/gnl/get_next_line_utils.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_atoi.o
Normal file
BIN
libftx/libft/ft_atoi.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_bzero.o
Normal file
BIN
libftx/libft/ft_bzero.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_calloc.o
Normal file
BIN
libftx/libft/ft_calloc.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isalnum.o
Normal file
BIN
libftx/libft/ft_isalnum.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isalpha.o
Normal file
BIN
libftx/libft/ft_isalpha.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isascii.o
Normal file
BIN
libftx/libft/ft_isascii.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isdigit.o
Normal file
BIN
libftx/libft/ft_isdigit.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isprint.o
Normal file
BIN
libftx/libft/ft_isprint.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_itoa.o
Normal file
BIN
libftx/libft/ft_itoa.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memchr.o
Normal file
BIN
libftx/libft/ft_memchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memcmp.o
Normal file
BIN
libftx/libft/ft_memcmp.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memcpy.o
Normal file
BIN
libftx/libft/ft_memcpy.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memmove.o
Normal file
BIN
libftx/libft/ft_memmove.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memset.o
Normal file
BIN
libftx/libft/ft_memset.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putchar_fd.o
Normal file
BIN
libftx/libft/ft_putchar_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putendl_fd.o
Normal file
BIN
libftx/libft/ft_putendl_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putnbr_fd.o
Normal file
BIN
libftx/libft/ft_putnbr_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putstr_fd.o
Normal file
BIN
libftx/libft/ft_putstr_fd.o
Normal file
Binary file not shown.
@ -6,13 +6,13 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/05 19:04:34 by cchauvet #+# #+# */
|
/* Created: 2022/10/05 19:04:34 by cchauvet #+# #+# */
|
||||||
/* Updated: 2022/10/28 19:23:45 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/06 19:33:51 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
static void *ft_cancel(char **tab, size_t len)
|
void *ft_cancel(char **tab, size_t len)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
BIN
libftx/libft/ft_split.o
Normal file
BIN
libftx/libft/ft_split.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strchr.o
Normal file
BIN
libftx/libft/ft_strchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strdup.o
Normal file
BIN
libftx/libft/ft_strdup.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_striteri.o
Normal file
BIN
libftx/libft/ft_striteri.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strjoin.o
Normal file
BIN
libftx/libft/ft_strjoin.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlcat.o
Normal file
BIN
libftx/libft/ft_strlcat.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlcpy.o
Normal file
BIN
libftx/libft/ft_strlcpy.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlen.o
Normal file
BIN
libftx/libft/ft_strlen.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strmapi.o
Normal file
BIN
libftx/libft/ft_strmapi.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strncmp.o
Normal file
BIN
libftx/libft/ft_strncmp.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strnstr.o
Normal file
BIN
libftx/libft/ft_strnstr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strrchr.o
Normal file
BIN
libftx/libft/ft_strrchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strtrim.o
Normal file
BIN
libftx/libft/ft_strtrim.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_substr.o
Normal file
BIN
libftx/libft/ft_substr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_tolower.o
Normal file
BIN
libftx/libft/ft_tolower.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_toupper.o
Normal file
BIN
libftx/libft/ft_toupper.o
Normal file
Binary file not shown.
BIN
libftx/libft/libft.a
Normal file
BIN
libftx/libft/libft.a
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
|
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/05 18:55:10 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/06 19:34:13 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,6 +15,7 @@
|
|||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
|
||||||
|
void *ft_cancel(char **tab, size_t len);
|
||||||
int ft_atoi(const char *nptr);
|
int ft_atoi(const char *nptr);
|
||||||
void ft_bzero(void *s, size_t n);
|
void ft_bzero(void *s, size_t n);
|
||||||
void *ft_calloc(size_t nmemb, size_t size);
|
void *ft_calloc(size_t nmemb, size_t size);
|
||||||
|
BIN
libftx/libftx.a
Normal file
BIN
libftx/libftx.a
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
|
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/05 18:59:40 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/06 19:34:38 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -19,11 +19,15 @@
|
|||||||
int ft_printf(const char *format, ...);
|
int ft_printf(const char *format, ...);
|
||||||
char *get_next_line(int fd);
|
char *get_next_line(int fd);
|
||||||
|
|
||||||
|
int ft_is_in(char *str, char c);
|
||||||
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
|
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
|
||||||
char *ft_strfjoin(char *s1, char *s2);
|
char *ft_strfjoin(char *s1, char *s2);
|
||||||
char *ft_strmerger(size_t arg_len, ...);
|
char *ft_strmerger(size_t arg_len, ...);
|
||||||
int ft_strcmp(char *s1, char *s2);
|
int ft_strcmp(char *s1, char *s2);
|
||||||
|
ssize_t ft_strchri(char *str, char c);
|
||||||
|
char *ft_strndup(char *src, size_t n);
|
||||||
|
|
||||||
|
void *ft_cancel(char **tab, size_t len);
|
||||||
int ft_atoi(const char *nptr);
|
int ft_atoi(const char *nptr);
|
||||||
void ft_bzero(void *s, size_t n);
|
void ft_bzero(void *s, size_t n);
|
||||||
void *ft_calloc(size_t nmemb, size_t size);
|
void *ft_calloc(size_t nmemb, size_t size);
|
||||||
|
BIN
libftx/printf/ft_dprintX.o
Normal file
BIN
libftx/printf/ft_dprintX.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintarg.o
Normal file
BIN
libftx/printf/ft_dprintarg.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintflag.o
Normal file
BIN
libftx/printf/ft_dprintflag.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintl_base.o
Normal file
BIN
libftx/printf/ft_dprintl_base.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintptr.o
Normal file
BIN
libftx/printf/ft_dprintptr.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintstrtab.o
Normal file
BIN
libftx/printf/ft_dprintstrtab.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintul.o
Normal file
BIN
libftx/printf/ft_dprintul.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintul_base.o
Normal file
BIN
libftx/printf/ft_dprintul_base.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintx.o
Normal file
BIN
libftx/printf/ft_dprintx.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_isarg.o
Normal file
BIN
libftx/printf/ft_isarg.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_isdigit.o
Normal file
BIN
libftx/printf/ft_isdigit.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_printf.a
Normal file
BIN
libftx/printf/ft_printf.a
Normal file
Binary file not shown.
BIN
libftx/printf/ft_printf.o
Normal file
BIN
libftx/printf/ft_printf.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_putchar_fd.o
Normal file
BIN
libftx/printf/ft_putchar_fd.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_putstr_fd.o
Normal file
BIN
libftx/printf/ft_putstr_fd.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_skipflag.o
Normal file
BIN
libftx/printf/ft_skipflag.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_strlen.o
Normal file
BIN
libftx/printf/ft_strlen.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_vdprintf.o
Normal file
BIN
libftx/printf/ft_vdprintf.o
Normal file
Binary file not shown.
49
main.c
49
main.c
@ -6,46 +6,45 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */
|
/* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/05 18:18:07 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/06 19:32:14 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "solong.h"
|
#include "solong.h"
|
||||||
|
/*
|
||||||
int main(int ac, char **av)
|
int maiin(int ac, char **av)
|
||||||
{
|
{
|
||||||
char **map;
|
char **map;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (ac)
|
if (ac)
|
||||||
{
|
{
|
||||||
map = ft_readfile(av[1]);
|
map = ft_readfile(av[1]);
|
||||||
ft_printf("%S", map);
|
ft_printf("%S", map);
|
||||||
|
i = 0;
|
||||||
|
while (map[i] != NULL)
|
||||||
|
{
|
||||||
|
free(map[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
free(map);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
int maiin(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
void *window_manager;
|
t_data data;
|
||||||
void *window;
|
|
||||||
t_shape shape;
|
|
||||||
|
|
||||||
window_manager = mlx_init();
|
ft_printf("Generating assets ...");
|
||||||
window = mlx_new_window(window_manager, 500, 500, "Hello world!");
|
ft_gen_assets();
|
||||||
shape.x = 10;
|
ft_printf("Generating assets [FINISHED]");
|
||||||
shape.y = 10;
|
data.mlx = mlx_init();
|
||||||
shape.size = 25;
|
data.window = mlx_new_window(data.mlx, WINDOW_SIZE, WINDOW_SIZE, "");
|
||||||
shape.color = ft_strdup("yellow");
|
// mlx_loop(window_manager);
|
||||||
shape.bcolor = ft_strdup("black");
|
ft_printf("%S", ft_get_player_map());
|
||||||
shape.shape = ft_strdup("square");
|
mlx_destroy_window(data.mlx, data.window);
|
||||||
printf("%d", ft_strcmp(shape.shape, "square"));
|
mlx_destroy_display(data.mlx);
|
||||||
ft_xpm_gen_file(shape);
|
free(data.mlx);
|
||||||
free(shape.color);
|
|
||||||
free(shape.bcolor);
|
|
||||||
free(shape.shape);
|
|
||||||
// mlx_loop(window_manager);
|
|
||||||
mlx_destroy_window(window_manager, window);
|
|
||||||
mlx_destroy_display(window_manager);
|
|
||||||
free(window_manager);
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
45
map.c
45
map.c
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/01/05 13:51:49 by cchauvet #+# #+# */
|
/* Created: 2023/01/05 13:51:49 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/05 19:00:31 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/06 19:36:36 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ char **ft_readfile(char *path)
|
|||||||
{
|
{
|
||||||
char **map;
|
char **map;
|
||||||
int fd;
|
int fd;
|
||||||
ssize_t nb_line;
|
size_t nb_line;
|
||||||
|
|
||||||
fd = open(path, O_RDONLY);
|
fd = open(path, O_RDONLY);
|
||||||
nb_line = 1;
|
nb_line = 1;
|
||||||
@ -26,6 +26,7 @@ char **ft_readfile(char *path)
|
|||||||
map[0] = get_next_line(fd);
|
map[0] = get_next_line(fd);
|
||||||
while (map[nb_line - 1] != NULL)
|
while (map[nb_line - 1] != NULL)
|
||||||
{
|
{
|
||||||
|
ft_strchr(map[nb_line - 1], '\n')[0] = '\0';
|
||||||
map[nb_line] = get_next_line(fd);
|
map[nb_line] = get_next_line(fd);
|
||||||
map = ft_tabrealloc(map, nb_line + 1, nb_line + 2);
|
map = ft_tabrealloc(map, nb_line + 1, nb_line + 2);
|
||||||
if (map == NULL)
|
if (map == NULL)
|
||||||
@ -34,3 +35,43 @@ char **ft_readfile(char *path)
|
|||||||
}
|
}
|
||||||
return (map);
|
return (map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t_map *ft_getmap(char *path)
|
||||||
|
{
|
||||||
|
t_map *map;
|
||||||
|
|
||||||
|
map = malloc(sizeof(t_map));
|
||||||
|
if (map == NULL)
|
||||||
|
return (NULL);
|
||||||
|
map->patern = ft_readfile(path);
|
||||||
|
if (ft_map_is_correct(map) == 0)
|
||||||
|
return (NULL);
|
||||||
|
return (map);
|
||||||
|
}
|
||||||
|
|
||||||
|
char **ft_get_player_map(t_map map)
|
||||||
|
{
|
||||||
|
char **player_map;
|
||||||
|
ssize_t y;
|
||||||
|
ssize_t i;
|
||||||
|
|
||||||
|
player_map = malloc(RENDER_DISTANCE * 2 + 2);
|
||||||
|
if (player_map == NULL)
|
||||||
|
return (NULL);
|
||||||
|
y = -RENDER_DISTANCE;
|
||||||
|
while (y < map.y_len - map.player_pos[1] - RENDER_DISTANCE)
|
||||||
|
{
|
||||||
|
i = map.player_pos[1] + y;
|
||||||
|
player_map[y] = ft_strndup(map.patern[i], RENDER_DISTANCE * 2 + 1);
|
||||||
|
if (player_map[y] == NULL)
|
||||||
|
{
|
||||||
|
ft_cancel(player_map, RENDER_DISTANCE - y);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
player_map[y] = NULL;
|
||||||
|
return (player_map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
35
maps/map_big.ber
Normal file
35
maps/map_big.ber
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
1111111111111111111111111111111111111111111111
|
||||||
|
1P0C000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1C00000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1011111111111111111111111111111111111111111101
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1111000000000000000000000000000000000000001111
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
100000000000000000000000000000000E000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1000000000000000000000000000000000000000000001
|
||||||
|
1111111111111111111111111111111111111111111111
|
5
maps/map_test.ber
Normal file
5
maps/map_test.ber
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
1111111111111
|
||||||
|
10010000000C1
|
||||||
|
1000011111001
|
||||||
|
1P0011E0000C1
|
||||||
|
1111111111111
|
6
maps/map_test2.ber
Normal file
6
maps/map_test2.ber
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
1111111111111111111111111111111111
|
||||||
|
1E0000000000000C00000C000000000001
|
||||||
|
1010010100100000101001000000010101
|
||||||
|
1010010010101010001001000000010101
|
||||||
|
1P0000000C00C0000000000000000000C1
|
||||||
|
1111111111111111111111111111111111
|
8
maps/map_test3.ber
Normal file
8
maps/map_test3.ber
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
111111111111111111111111111111111
|
||||||
|
1P1C000000010101010C100C001000001
|
||||||
|
10101101110001C00000100C001011101
|
||||||
|
10101000C10101110100101110101C101
|
||||||
|
10C00001010000C00100001C101010101
|
||||||
|
111111110101010101111010101010101
|
||||||
|
1E0000000100C001000C1C10000010001
|
||||||
|
111111111111111111111111111111111
|
3
maps/not_minimun.ber
Normal file
3
maps/not_minimun.ber
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
11111
|
||||||
|
10CE1
|
||||||
|
11111
|
5
maps/not_possible.ber
Normal file
5
maps/not_possible.ber
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
1111111111111
|
||||||
|
1P1C010110001
|
||||||
|
1011100010101
|
||||||
|
10000010001E1
|
||||||
|
1111111111111
|
4
maps/not_rectangular.ber
Normal file
4
maps/not_rectangular.ber
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
11111
|
||||||
|
1P01
|
||||||
|
10CE1
|
||||||
|
11111
|
4
maps/not_surrounded.ber
Normal file
4
maps/not_surrounded.ber
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
11111
|
||||||
|
1PCE1
|
||||||
|
10001
|
||||||
|
1111E
|
104
parsing.c
Normal file
104
parsing.c
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* parsing.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/01/05 20:14:44 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/01/06 18:53:28 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "solong.h"
|
||||||
|
|
||||||
|
int ft_test_map_dimmention(t_map *map)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = ft_strlen(map->patern[0]);
|
||||||
|
i = 1;
|
||||||
|
while (map->patern[i] != NULL)
|
||||||
|
{
|
||||||
|
if (ft_strlen(map->patern[i]) != len)
|
||||||
|
return (0);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
map->x_len = len;
|
||||||
|
map->y_len = i;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_test_map_content1(t_map *map)
|
||||||
|
{
|
||||||
|
size_t x;
|
||||||
|
size_t y;
|
||||||
|
size_t nb_collectable;
|
||||||
|
|
||||||
|
nb_collectable = 0;
|
||||||
|
y = 0;
|
||||||
|
while (y < map->y_len)
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
while (x < map->x_len)
|
||||||
|
{
|
||||||
|
if (ft_is_in("01CEP", map->patern[y][x]) == 0)
|
||||||
|
return (0);
|
||||||
|
if (map->patern[y][x] == 'C')
|
||||||
|
nb_collectable++;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if (nb_collectable == 0)
|
||||||
|
return (0);
|
||||||
|
map->nb_collectable = nb_collectable;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_test_map_content2(t_map *map)
|
||||||
|
{
|
||||||
|
ssize_t cord[2];
|
||||||
|
|
||||||
|
cord[1] = -1;
|
||||||
|
while ((size_t) ++cord[1] < map->y_len)
|
||||||
|
{
|
||||||
|
cord[0] = -1;
|
||||||
|
while ((size_t) ++cord[0] < map->x_len)
|
||||||
|
{
|
||||||
|
if (map->patern[cord[1]][cord[0]] == 'E')
|
||||||
|
{
|
||||||
|
map->exit[0] = cord[0];
|
||||||
|
map->exit[1] = cord[1];
|
||||||
|
map->exit[2]++;
|
||||||
|
}
|
||||||
|
else if (map->patern[cord[1]][cord[0]] == 'P')
|
||||||
|
{
|
||||||
|
map->player_pos[0] = cord[0];
|
||||||
|
map->player_pos[1] = cord[1];
|
||||||
|
map->player_pos[2]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (map->player_pos[2] == 1 && map->exit[2] == 1)
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_test_map_is_finishable(t_map map)
|
||||||
|
{
|
||||||
|
(void) map;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_map_is_correct(t_map *map)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = ft_test_map_content1(map);
|
||||||
|
i += ft_test_map_content2(map);
|
||||||
|
i += ft_test_map_dimmention(map);
|
||||||
|
i += ft_test_map_is_finishable(*map);
|
||||||
|
return (i == 4);
|
||||||
|
}
|
2
shape.c
2
shape.c
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/01/04 19:13:01 by cchauvet #+# #+# */
|
/* Created: 2023/01/04 19:13:01 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/04 19:55:25 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/06 17:54:37 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
37
solong.h
37
solong.h
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/01/04 16:20:03 by cchauvet #+# #+# */
|
/* Created: 2023/01/04 16:20:03 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/05 17:40:19 by cchauvet ### ########.fr */
|
/* Updated: 2023/01/06 19:29:56 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -18,15 +18,43 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include "minilibx-linux/mlx.h"
|
# include "minilibx-linux/mlx.h"
|
||||||
|
# define CASE_SIZE 64
|
||||||
|
# define XPM_HEADER "\nstatic char * XFACE[] = {\""
|
||||||
|
# define COLORS "black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen"
|
||||||
|
# define BACKGROUND_COLOR "black"
|
||||||
|
# define SHAPES "square"
|
||||||
|
# define RENDER_DISTANCE 5
|
||||||
|
# define WINDOW_SIZE (RENDER_DISTANCE * 2 + 1) * CASE_SIZE
|
||||||
typedef struct s_shape
|
typedef struct s_shape
|
||||||
{
|
{
|
||||||
char *color;
|
char *color;
|
||||||
char *bcolor;
|
char *bcolor;
|
||||||
char *shape;
|
char *shape;
|
||||||
size_t size;
|
size_t size;
|
||||||
size_t x;
|
|
||||||
size_t y;
|
|
||||||
} t_shape;
|
} t_shape;
|
||||||
|
|
||||||
|
typedef struct s_map
|
||||||
|
{
|
||||||
|
size_t x_len;
|
||||||
|
size_t y_len;
|
||||||
|
size_t nb_collectable;
|
||||||
|
char **patern;
|
||||||
|
size_t player_pos[3];
|
||||||
|
size_t exit[3];
|
||||||
|
} t_map;
|
||||||
|
|
||||||
|
typedef struct s_data
|
||||||
|
{
|
||||||
|
void *mlx;
|
||||||
|
void *window;
|
||||||
|
char *bcolor;
|
||||||
|
char *pcolor;
|
||||||
|
char *ccolor;
|
||||||
|
char *wcolor;
|
||||||
|
size_t size;
|
||||||
|
} t_data;
|
||||||
|
|
||||||
|
t_map *ft_getmap(char *path);
|
||||||
void ft_draw_xpm(void *mlx, void *window, char *file, size_t *cord);
|
void ft_draw_xpm(void *mlx, void *window, char *file, size_t *cord);
|
||||||
void ft_draw_square(void *window_manager, void *window, t_shape shape);
|
void ft_draw_square(void *window_manager, void *window, t_shape shape);
|
||||||
char *xpm_square_generator(t_shape);
|
char *xpm_square_generator(t_shape);
|
||||||
@ -35,4 +63,7 @@ char *ft_square(char c, size_t x_len, size_t y_len);
|
|||||||
char *ft_triangle(char c, char b, size_t x_len, size_t y_len);
|
char *ft_triangle(char c, char b, size_t x_len, size_t y_len);
|
||||||
char *ft_xpm_gen_file(t_shape shape);
|
char *ft_xpm_gen_file(t_shape shape);
|
||||||
char **ft_readfile(char *path);
|
char **ft_readfile(char *path);
|
||||||
|
int ft_map_is_correct(t_map *map);
|
||||||
|
int ft_gen_assets(void);
|
||||||
|
char **ft_get_player_map(t_map map);
|
||||||
#endif
|
#endif
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user