aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_drawsquare.c3
-rw-r--r--src/ft_exit.c3
-rw-r--r--src/ft_get_res.c22
-rw-r--r--src/ft_map_error.c9
-rw-r--r--src/ft_parse_map.c12
-rw-r--r--src/main.c3
6 files changed, 48 insertions, 4 deletions
diff --git a/src/ft_drawsquare.c b/src/ft_drawsquare.c
index 78ebd8c..b37dc77 100644
--- a/src/ft_drawsquare.c
+++ b/src/ft_drawsquare.c
@@ -2,11 +2,12 @@
#include <cub3d.h>
void
-ft_drawsquare(t_win *wlist, int a, int b)
+ft_drawsquare(t_win *wlist, t_cub *clist, int a, int b)
{
int x;
int y;
+ (void)clist;
x = a;
y = b;
while (x > a - 40)
diff --git a/src/ft_exit.c b/src/ft_exit.c
index a5b7276..5a4ef73 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -2,11 +2,12 @@
#include <stdlib.h>
#include <inttypes.h>
-void
+int
ft_exit(uint8_t exit_code)
{
ft_printf("Exiting program\n");
if (exit_code < 0 || exit_code > 0)
ft_printf("Exit code: %hhu\n", exit_code);
exit(exit_code);
+ return (0);
}
diff --git a/src/ft_get_res.c b/src/ft_get_res.c
new file mode 100644
index 0000000..c610fc1
--- /dev/null
+++ b/src/ft_get_res.c
@@ -0,0 +1,22 @@
+#include <libft.h>
+#include <cub3d.h>
+
+int
+ft_get_res(int fd, t_win *wlist)
+{
+ char *line;
+ char **words;
+ int i;
+
+ (void)wlist;
+ get_next_line(fd, &line);
+ words = ft_split(line, ' ');
+ i = 0;
+ while (words)
+ {
+ ft_printf("[%s] ", words[i]);
+ i++;
+ }
+ ft_printf("\n");
+ return (0);
+}
diff --git a/src/ft_map_error.c b/src/ft_map_error.c
new file mode 100644
index 0000000..bffb6d1
--- /dev/null
+++ b/src/ft_map_error.c
@@ -0,0 +1,9 @@
+#include <libft.h>
+#include <cub3d.h>
+
+int
+ft_map_error(unsigned int line)
+{
+ ft_printf("\033[1;31mMap error: line %d\033[0m\n", line);
+ return (ft_exit(1));
+}
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index baf3b5f..d2fbe0d 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -1,8 +1,18 @@
#include <libft.h>
#include <cub3d.h>
#include <stdlib.h>
+#include <fcntl.h>
+
+/*
+** I can't close
+*/
void
-ft_parse_map(t_cub *clist)
+ft_parse_map(t_win *wlist, t_cub *clist, const char *map_path)
{
+ int fd;
+
+ (void)clist;
+ fd = open(map_path, O_RDONLY);
+ ft_get_res(fd, wlist);
}
diff --git a/src/main.c b/src/main.c
index c7fbc58..d23320b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -11,8 +11,9 @@ int
wlist = ft_init_win();
clist = ft_init_cub();
+ ft_parse_map(wlist, clist, "map/map_one.cub");
mlx_key_hook(wlist->winptr, ft_key_event, wlist);
- ft_drawsquare(wlist, 80, 80);
+ ft_drawsquare(wlist, clist, 80, 80);
mlx_loop(wlist->wlx);
ft_memdel(clist);
return (0);