Compare commits

..

No commits in common. "d7256c47a534ec0e69117cf378e35daa064f81d9" and "909bb442b66382028545767d511221480f517387" have entirely different histories.

116 changed files with 347 additions and 687 deletions

View File

@ -1,4 +1,4 @@
SRCS = asset.c draw.c main.c map.c parsing.c shape.c xpm.c
SRCS = draw.c main.c shape.c xpm.c
OBJ = ${SRCS:.c=.o}

74
asset.c
View File

@ -1,74 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}

BIN
asset.o

Binary file not shown.

34
draw.c
View File

@ -6,42 +6,22 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/13 15:49:23 by cchauvet #+# #+# */
/* Updated: 2023/01/06 18:49:39 by cchauvet ### ########.fr */
/* Updated: 2023/01/04 19:05:04 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
void ft_draw_xpm(void *mlx, void *window, char *img_path, size_t *cord)
void ft_draw_xpm(void *mlx, void *window, char *file, size_t *cord)
{
int bozo;
char *img_path;
void *img;
int bozo;
img_path = ft_strmerger(2, XPM_PATH, file);
if (img_path == NULL)
return ;
img = mlx_xpm_file_to_image(mlx, img_path, &bozo, &bozo);
mlx_put_image_to_window(mlx, window, img, cord[0], cord[1]);
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);
}

BIN
draw.o

Binary file not shown.

View File

View File

@ -1,4 +1,4 @@
# **************************************************************************** #
:# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
@ -6,19 +6,19 @@
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2023/01/05 20:32:04 by cchauvet ### ########.fr #
# Updated: 2023/01/04 20:00:03 by cchauvet ### ########.fr #
# #
# **************************************************************************** #
CC = clang
SRCS = ft_strchri.c ft_strcmp.c ft_strfjoin.c ft_strmerger.c ft_strndup.c ft_tabrealloc.c ft_is_in.c
SRCS = ft_strcmp.c ft_strfjoin.c ft_strmerger.c
OBJS = $(SRCS:.c=.o)
NAME = extra.a
CFLAGS = -Wall -Werror -Wextra -g
CFLAGS = -Wall -Werror -Wextra
%.o: %.c extra.h
$(CC) $(CFLAGS) -c -o $@ $<

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */
/* Updated: 2023/01/05 20:31:50 by cchauvet ### ########.fr */
/* Updated: 2023/01/04 19:59:10 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,9 +18,5 @@
char *ft_strfjoin(char *s1, char *s2);
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_strndup(char *src, size_t n);
ssize_t ft_strchri(char *str, char c);
int ft_strcmp(char *s1, char *s2);
#endif

View File

@ -1,26 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}

Binary file not shown.

View File

@ -1,28 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 19:20:47 by cchauvet #+# #+# */
/* Updated: 2023/01/05 13:20:20 by cchauvet ### ########.fr */
/* Updated: 2023/01/04 19:22:20 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,10 +14,7 @@
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] == s2[i] && s1[i] != '\0')
i++;
return (s1[i] - s2[i]);
while (*s1 == *s2 && *s1 != '\0')
s1++;
return (*s1 - *s2);
}

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 14:06:04 by cchauvet #+# #+# */
/* Updated: 2023/01/05 19:38:35 by cchauvet ### ########.fr */
/* Updated: 2023/01/04 14:17:40 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,20 +14,17 @@
char *ft_strfjoin(char *s1, char *s2)
{
ssize_t i;
ssize_t y;
size_t i;
size_t y;
char *out;
out = malloc((ft_strlen(s1) + ft_strlen(s2) + 1) * sizeof(char));
if (out == NULL)
return (NULL);
i = 0;
i = -1;
if (s1 != NULL)
while (s1[i] != '\0')
{
while (s1[++i] != '\0')
out[i] = s1[i];
i++;
}
free(s1);
y = -1;
if (s2 != NULL)

Binary file not shown.

Binary file not shown.

View File

@ -1,32 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strndup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/26 00:55:44 by cchauvet #+# #+# */
/* Updated: 2023/01/05 19:27:03 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char *ft_strndup(char *src, size_t n)
{
char *out;
size_t i;
if (src[0] == '\0')
return (NULL);
out = ft_calloc(n + 1, sizeof(char));
if (out == NULL)
return (NULL);
i = 0;
while (src[i] != '\0' && i < n)
{
out[i] = src[i];
i++;
}
return (out);
}

Binary file not shown.

View File

@ -1,33 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tabrealloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 18:58:48 by cchauvet #+# #+# */
/* Updated: 2023/01/05 18:58:59 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size)
{
char **new;
size_t i;
new = malloc(new_size * sizeof(char *));
if (new == NULL)
return (NULL);
i = 0;
while (i < current_size)
{
new[i] = tab[i];
i++;
}
free(tab);
return (new);
}

Binary file not shown.

View File

@ -6,17 +6,17 @@
# By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/12/14 15:49:18 by cchauvet #+# #+# #
# Updated: 2023/01/05 19:22:40 by cchauvet ### ########.fr #
# Updated: 2022/12/14 16:08:19 by cchauvet ### ########.fr #
# #
# **************************************************************************** #
SRCS = get_next_line.c
SRCS = get_next_line.c get_next_line_utils.c
OBJS = ${SRCS:.c=.o}
NAME = get_next_line.a
CFLAGS = -Wall -Werror -Wextra -g
CFLAGS = -Wall -Werror -Wextra
CC = clang

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/26 00:52:47 by cchauvet #+# #+# */
/* Updated: 2023/01/05 13:07:10 by cchauvet ### ########.fr */
/* Updated: 2022/11/14 15:37:48 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,7 +36,7 @@ char *ft_getline(int fd)
stash = NULL;
buf = NULL;
while (ft_strchri(stash, '\n') == -1)
while (ft_strchr(stash, '\n') == -1)
{
buf = ft_getstash(fd);
if (buf == NULL)
@ -54,7 +54,7 @@ char *ft_getreturn(char *str)
if (str == NULL)
return (NULL);
i = ft_strchri(str, '\n') + 1;
i = ft_strchr(str, '\n') + 1;
if (i == 0)
i = ft_strlen(str);
return (ft_strndup(str, i));
@ -67,7 +67,7 @@ char *ft_getextra(char *str)
if (str == NULL)
return (NULL);
i = ft_strchri(str, '\n') + 1;
i = ft_strchr(str, '\n') + 1;
if (i == 0)
return (NULL);
j = ft_strlen(str + i);
@ -81,7 +81,7 @@ char *get_next_line(int fd)
char *buf2;
buf2 = stash;
if (ft_strchri(stash, '\n') == -1)
if (ft_strchr(stash, '\n') == -1)
{
buf1 = ft_getline(fd);
buf2 = ft_strfjoin(stash, buf1);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/14 15:38:06 by cchauvet #+# #+# */
/* Updated: 2023/01/05 19:27:45 by cchauvet ### ########.fr */
/* Updated: 2023/01/04 20:05:54 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,7 +17,12 @@
# ifndef BUFFER_SIZE
# define BUFFER_SIZE 42
# endif
# include "../libft/libft.h"
# include "../extra/extra.h"
void *ft_calloc(size_t nmemb, size_t size);
void *ft_realloc(void *ptr, size_t size);
char *ft_strfjoin(char *dst, char *src);
char *ft_strndup(char *src, size_t n);
size_t ft_strlen(char *str);
ssize_t ft_strchr(char *str, char c);
char *get_next_line(int fd);
#endif

Binary file not shown.

View File

@ -0,0 +1,106 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/26 00:55:44 by cchauvet #+# #+# */
/* Updated: 2022/11/14 15:39:50 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.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);
}
size_t ft_strlen(char *str)
{
size_t i;
if (str == NULL)
return (0);
i = 0;
while (str[i] != '\0')
i++;
return (i);
}
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 *out;
size_t i;
if (src[0] == '\0')
return (NULL);
out = ft_calloc(n + 1, sizeof(char));
if (out == NULL)
return (NULL);
i = 0;
while (src[i] != '\0' && i < n)
{
out[i] = src[i];
i++;
}
return (out);
}
ssize_t ft_strchr(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);
}

Binary file not shown.

View File

@ -6,7 +6,7 @@
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2023/01/05 17:44:37 by cchauvet ### ########.fr #
# Updated: 2023/01/04 15:35:42 by cchauvet ### ########.fr #
# #
# **************************************************************************** #
@ -63,7 +63,7 @@ BOBJS = $(BSRCS:.c=.o)
NAME = libft.a
CFLAGS = -Wall -Werror -Wextra -g
CFLAGS = -Wall -Werror -Wextra
%.o: %.c libft.h
$(CC) $(CFLAGS) -c -o $@ $<

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,13 +6,13 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/29 22:23:35 by cchauvet #+# #+# */
/* Updated: 2023/01/05 18:54:54 by cchauvet ### ########.fr */
/* Updated: 2022/09/29 22:24:53 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putchar_fd(int fd, char c)
void ft_putchar_fd(char c, int fd)
{
write(fd, &c, 1);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,13 +6,13 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 19:04:34 by cchauvet #+# #+# */
/* Updated: 2023/01/06 19:33:51 by cchauvet ### ########.fr */
/* Updated: 2022/10/28 19:23:45 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_cancel(char **tab, size_t len)
static void *ft_cancel(char **tab, size_t len)
{
size_t i;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,18 +6,15 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 12:03:59 by cchauvet #+# #+# */
/* Updated: 2023/01/05 17:46:12 by cchauvet ### ########.fr */
/* Updated: 2022/09/27 09:02:11 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stddef.h>
size_t ft_strlen(const char *s)
{
size_t length;
if (s == NULL)
return (0);
length = 0;
while (s[length])
length++;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2023/01/06 19:34:13 by cchauvet ### ########.fr */
/* Updated: 2023/01/04 15:20:30 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,7 +15,6 @@
# include <stdlib.h>
# include <unistd.h>
void *ft_cancel(char **tab, size_t len);
int ft_atoi(const char *nptr);
void ft_bzero(void *s, size_t n);
void *ft_calloc(size_t nmemb, size_t size);
@ -47,7 +46,7 @@ char **ft_split(char const *s, char c);
char *ft_itoa(int n);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
void ft_striteri(char *s, void (*f)(unsigned int, char*));
void ft_putchar_fd(int fd, char c);
void ft_putchar_fd(char c, int fd);
void ft_putstr_fd(char *s, int fd);
void ft_putendl_fd(char *s, int fd);
void ft_putnbr_fd(int n, int fd);

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2023/01/06 19:34:38 by cchauvet ### ########.fr */
/* Updated: 2023/01/04 20:07:06 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,15 +19,10 @@
int ft_printf(const char *format, ...);
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_strfjoin(char *s1, char *s2);
char *ft_strmerger(size_t arg_len, ...);
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);
void ft_bzero(void *s, size_t n);
void *ft_calloc(size_t nmemb, size_t size);
@ -59,10 +54,10 @@ char **ft_split(char const *s, char c);
char *ft_itoa(int n);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
void ft_striteri(char *s, void (*f)(unsigned int, char*));
void ft_putchar_fd(int fd, char c);
void ft_putstr_fd(int fd, char *s);
void ft_putendl_fd(int fd, char *s);
void ft_putnbr_fd(int fd, int n);
void ft_putchar_fd(char c, int fd);
void ft_putstr_fd(char *s, int fd);
void ft_putendl_fd(char *s, int fd);
void ft_putnbr_fd(int n, int fd);
typedef struct s_list
{

View File

@ -6,22 +6,22 @@
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2023/01/05 18:25:05 by cchauvet ### ########.fr #
# Updated: 2023/01/04 15:36:08 by cchauvet ### ########.fr #
# #
# **************************************************************************** #
CC = clang
SRCS = ft_dprintarg.c ft_dprintflag.c ft_dprintl_base.c ft_dprintptr.c ft_dprintstrtab.c ft_dprintul_base.c ft_dprintul.c ft_dprintx.c ft_dprintX.c ft_isarg.c ft_isdigit.c ft_printf.c ft_putchar_fd.c ft_putstr_fd.c ft_skipflag.c ft_strlen.c ft_vdprintf.c
SRCS = ft_dprintul_base.c ft_isdigit.c ft_dprintul.c ft_dprintx.c ft_dprintflag.c ft_skipflag.c ft_vdprintf.c ft_dprintl_base.c ft_dprintX.c ft_dprintptr.c ft_strlen.c ft_putstr_fd.c ft_dprintarg.c ft_printf.c ft_putchar_fd.c ft_isarg.c
OBJS = ${SRCS:.c=.o}
NAME = ft_printf.a
CFLAG = -Wall -Werror -Wextra -g
CFLAG = -Wall -Werror -Wextra
%.o: %.c
${CC} ${CFLAG} -c -o $@ $<
${CC} ${CFLAGS} -c -o $@ $<
all: ${NAME}

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/23 18:08:31 by cchauvet #+# #+# */
/* Updated: 2023/01/05 17:37:12 by cchauvet ### ########.fr */
/* Updated: 2022/10/23 18:54:41 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -24,8 +24,6 @@ int ft_dprintarg(int fd, int arg, va_list args)
return (ft_dprintul(fd, va_arg(args, unsigned int)));
if (arg == 'c')
return (ft_putchar_fd(fd, va_arg(args, int)));
if (arg == 'S')
return (ft_dprintstrtab(fd, va_arg(args, char **)));
if (arg == 's')
return (ft_putstr_fd(fd, va_arg(args, char *)));
if (arg == '%')

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,29 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dprintstrtab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 17:26:55 by cchauvet #+# #+# */
/* Updated: 2023/01/05 18:52:56 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_dprintstrtab(int fd, char **tab)
{
size_t index;
int i;
i = 0;
index = 0;
while (tab[index] != NULL)
{
i += ft_putstr_fd(fd, tab[index]) + 1;
ft_putchar_fd(fd, '\n');
index++;
}
return (i);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/11 22:37:41 by cchauvet #+# #+# */
/* Updated: 2023/01/05 18:26:24 by cchauvet ### ########.fr */
/* Updated: 2022/10/12 16:09:22 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,7 @@ int ft_isarg(int c)
if (c == '\0')
return (1);
flags = "cspdiuxX%S";
flags = "cspdiuxX%";
while (*flags)
{
if (*flags == c)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
/* Updated: 2023/01/05 17:36:39 by cchauvet ### ########.fr */
/* Updated: 2022/11/07 19:41:50 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -29,7 +29,6 @@ int ft_dprintx(int fd, unsigned int n);
int ft_dprint_upperx(int fd, unsigned int n);
int ft_dprintflag(int fd, const char *flag, va_list va);
int ft_dprintarg(int fd, int c, va_list va);
int ft_dprintstrtab(int fd, char **tab);
int ft_printf(const char *format, ...);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

53
main.c
View File

@ -6,45 +6,32 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/12 17:20:17 by cchauvet #+# #+# */
/* Updated: 2023/01/06 19:32:14 by cchauvet ### ########.fr */
/* Updated: 2023/01/04 19:47:28 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
/*
int maiin(int ac, char **av)
{
char **map;
int i;
if (ac)
{
map = ft_readfile(av[1]);
ft_printf("%S", map);
i = 0;
while (map[i] != NULL)
{
free(map[i]);
i++;
}
free(map);
}
return (0);
}
*/
int main(void)
{
t_data data;
void *window_manager;
void *window;
t_shape shape;
ft_printf("Generating assets ...");
ft_gen_assets();
ft_printf("Generating assets [FINISHED]");
data.mlx = mlx_init();
data.window = mlx_new_window(data.mlx, WINDOW_SIZE, WINDOW_SIZE, "");
// mlx_loop(window_manager);
ft_printf("%S", ft_get_player_map());
mlx_destroy_window(data.mlx, data.window);
mlx_destroy_display(data.mlx);
free(data.mlx);
return (1);
window_manager = mlx_init();
window = mlx_new_window(window_manager, 500, 500, "Hello world!");
shape.x = 10;
shape.y = 10;
shape.size = 100;
shape.color = ft_strdup("purple");
shape.bcolor = ft_strdup("black");
shape.shape = ft_strdup("square");
ft_xpm_gen_file(shape);
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);
}

BIN
main.o

Binary file not shown.

77
map.c
View File

@ -1,77 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/05 13:51:49 by cchauvet #+# #+# */
/* Updated: 2023/01/06 19:36:36 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "solong.h"
char **ft_readfile(char *path)
{
char **map;
int fd;
size_t nb_line;
fd = open(path, O_RDONLY);
nb_line = 1;
map = malloc(sizeof(char *) * 2);
if (map == NULL)
return (NULL);
map[0] = get_next_line(fd);
while (map[nb_line - 1] != NULL)
{
ft_strchr(map[nb_line - 1], '\n')[0] = '\0';
map[nb_line] = get_next_line(fd);
map = ft_tabrealloc(map, nb_line + 1, nb_line + 2);
if (map == NULL)
return (NULL);
nb_line++;
}
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);
}

BIN
map.o

Binary file not shown.

View File

@ -1,35 +0,0 @@
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

View File

@ -1,5 +0,0 @@
1111111111111
10010000000C1
1000011111001
1P0011E0000C1
1111111111111

Some files were not shown because too many files have changed in this diff Show More