aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-09 15:12:52 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-09 15:12:52 +0100
commita1e2fbb1502564a7d49a47ca1949aeec83ea67b2 (patch)
tree36a4068779ca81b81d14281a36d338034c36917d
parentSmooth (diff)
download42-cub3d-a1e2fbb1502564a7d49a47ca1949aeec83ea67b2.tar.gz
42-cub3d-a1e2fbb1502564a7d49a47ca1949aeec83ea67b2.tar.bz2
42-cub3d-a1e2fbb1502564a7d49a47ca1949aeec83ea67b2.tar.xz
42-cub3d-a1e2fbb1502564a7d49a47ca1949aeec83ea67b2.tar.zst
42-cub3d-a1e2fbb1502564a7d49a47ca1949aeec83ea67b2.zip
New function, trying to close properly
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h1
-rw-r--r--src/ft_click_close.c26
-rw-r--r--src/main.c4
4 files changed, 30 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index cc7001c..1234467 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@ INCS = cub3d.h
SRCS_NAME = main.c
SRCS_NAME += ft_init_lists.c
SRCS_NAME += ft_key_events.c
+SRCS_NAME += ft_click_close.c
SRCS_NAME += ft_exit.c
SRCS_NAME += ft_drawsquare.c
SRCS_NAME += ft_parse_map.c
diff --git a/inc/cub3d.h b/inc/cub3d.h
index b2ba3b7..e7615e9 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -128,6 +128,7 @@ typedef struct s_cub
t_win *ft_init_win(void);
t_cub *ft_init_cub(void);
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);
void ft_drawsquare(int a, int b, int rgb, t_cub *clist);
void ft_parse_map(const char *map_path, t_cub *clist);
diff --git a/src/ft_click_close.c b/src/ft_click_close.c
new file mode 100644
index 0000000..87c0bbf
--- /dev/null
+++ b/src/ft_click_close.c
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/* LE - / */
+/* / */
+/* ft_click_close.c .:: .:/ . .:: */
+/* +:+:+ +: +: +:+:+ */
+/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
+/* #+# #+ #+ #+# */
+/* Created: 2020/02/09 15:12:16 by rbousset #+# ## ## #+# */
+/* Updated: 2020/02/09 15:12:17 by rbousset ### #+. /#+ ###.fr */
+/* / */
+/* / */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <mlx.h>
+#include <stdlib.h>
+
+int
+ ft_click_close(int keycode, t_cub *clist)
+{
+ ft_printf("Button [%d] pressed\n", keycode);
+ if (keycode == 8800)
+ return (ft_exit(0, clist));
+ return (0);
+}
diff --git a/src/main.c b/src/main.c
index 5e05c02..b1437cc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,8 +40,8 @@ int
ft_parse_map(argv[1], clist);
if (ft_init_winlx(clist) < 0)
return (ft_exit(3, clist));
- mlx_hook(clist->wlist->winptr, 2, 1L<<1, ft_key_event, clist);
- /* mlx_key_hook(clist->wlist->winptr, ft_key_event, clist); */
+ mlx_hook(clist->wlist->winptr, 2, 1L << 1, ft_key_event, clist);
+ mlx_hook(clist->wlist->winptr, 17, 1L << 3, ft_click_close, clist);
ft_drawmap(clist);
mlx_loop(clist->wlist->wlx);
return (0);