aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-09 20:18:55 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-09 20:18:55 +0100
commita19222c3f309105d9ea7d93fc4a95da6e5e68a33 (patch)
tree92044dfc9ae5aa4a38280cf38b95e75be5210593
parentBetter names (diff)
download42-cub3d-a19222c3f309105d9ea7d93fc4a95da6e5e68a33.tar.gz
42-cub3d-a19222c3f309105d9ea7d93fc4a95da6e5e68a33.tar.bz2
42-cub3d-a19222c3f309105d9ea7d93fc4a95da6e5e68a33.tar.xz
42-cub3d-a19222c3f309105d9ea7d93fc4a95da6e5e68a33.tar.zst
42-cub3d-a19222c3f309105d9ea7d93fc4a95da6e5e68a33.zip
new file
Diffstat (limited to '')
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h3
-rw-r--r--src/ft_hooks_and_loops.c23
-rw-r--r--src/main.c4
4 files changed, 26 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 3bf1c00..f645188 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,7 @@ INCS = cub3d.h
#------------------------------------------------------------------------------#
SRCS_NAME = main.c
SRCS_NAME += ft_init_lists.c
+SRCS_NAME += ft_hooks_and_loops.c
SRCS_NAME += ft_key_events.c
SRCS_NAME += ft_click_close.c
SRCS_NAME += ft_exit.c
diff --git a/inc/cub3d.h b/inc/cub3d.h
index bc9f1bd..ce7b0c1 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -126,8 +126,7 @@ typedef struct s_cub
*/
int8_t ft_init_cub3d(t_cub **clist);
-/* t_win *ft_init_win(void); */
-/* t_cub *ft_init_cub(void); */
+void ft_hooks_and_loops(t_win *wl, t_cub *cl);
int ft_key_event(int keycode, t_cub *clist);
int ft_click_close(int keycode, t_cub *clist);
int ft_exit(uint8_t exit_code, t_cub *clist);
diff --git a/src/ft_hooks_and_loops.c b/src/ft_hooks_and_loops.c
new file mode 100644
index 0000000..30d65f4
--- /dev/null
+++ b/src/ft_hooks_and_loops.c
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* LE - / */
+/* / */
+/* ft_hooks_and_loops.c .:: .:/ . .:: */
+/* +:+:+ +: +: +:+:+ */
+/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
+/* #+# #+ #+ #+# */
+/* Created: 2020/02/09 20:16:25 by rbousset #+# ## ## #+# */
+/* Updated: 2020/02/09 20:16:27 by rbousset ### #+. /#+ ###.fr */
+/* / */
+/* / */
+/* ************************************************************************** */
+
+#include <cub3d.h>
+#include <mlx.h>
+
+void
+ ft_hooks_and_loops(t_win *wl, t_cub *cl)
+{
+ mlx_hook(wl->winptr, 2, 1L << 1, ft_key_event, cl);
+ mlx_hook(wl->winptr, 17, 0L, ft_click_close, cl);
+ mlx_loop(wl->wlx);
+}
diff --git a/src/main.c b/src/main.c
index 77da0bc..39b5f7c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,8 +33,6 @@ int
if (ft_init_winlx(clist) < 0)
return (ft_exit(3, clist));
ft_drawmap(clist);
- mlx_hook(clist->wlist->winptr, 2, 1L << 1, ft_key_event, clist);
- mlx_hook(clist->wlist->winptr, 17, 0L, ft_click_close, clist);
- mlx_loop(clist->wlist->wlx);
+ ft_hooks_and_loops(clist->wlist, clist);
return (0);
}