diff --git a/srcs/main.c b/srcs/main.c index 40ed9a1..0c0ab12 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/13 16:42:55 by apommier #+# #+# */ -/* Updated: 2022/02/14 23:49:53 by apommier ### ########.fr */ +/* Updated: 2022/02/15 00:08:06 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -118,27 +118,6 @@ char **set_map(char **argv) return (map_tab); } -int button_press(int code, t_data *img) -{ - int i; - - - (void)code; - printf("img in buttom = %p\n", img); - printf("move = %d\n", img->move); - //printf("img->mlx = %p\n", img->mlx); - i = 0; - mlx_destroy_window(img->mlx, img->mlx_win); - mlx_destroy_display(img->mlx); - if (img->mlx) - free(img->mlx); - while (img->map_tab[i]) - free(img->map_tab[i++]); - free(img->map_tab); - //quit_game(img); - exit(1); -} - int main(int argc, char **argv) { t_data img; @@ -159,11 +138,7 @@ int main(int argc, char **argv) img.mlx_win = mlx_new_window(img.mlx, ft_strlen(img.map_tab[0]) * 32, height * 32, "Hungry Bear"); print_map(img.map_tab, &img); - printf("img in main= %p\n", &img); - //mlx_hook(img.mlx_win, DestroyNotify, NoEventMask, &button_press, &img); - mlx_hook(img.mlx_win, 2, 1L << 0, &key_press, &img); - mlx_hook(img.mlx_win, 33, 1L << 17, &button_press, &img); - //mlx_key_hook(img.mlx_win, &key_press, &img); + mlx_hook(img.mlx_win, 17, 0L, &quit_game, &img); mlx_loop(img.mlx); } diff --git a/srcs/main.o b/srcs/main.o deleted file mode 100644 index 5fc5afc..0000000 Binary files a/srcs/main.o and /dev/null differ diff --git a/srcs/parsing.o b/srcs/parsing.o deleted file mode 100644 index 06e5877..0000000 Binary files a/srcs/parsing.o and /dev/null differ diff --git a/srcs/print_map.o b/srcs/print_map.o index e5f4591..724b160 100644 Binary files a/srcs/print_map.o and b/srcs/print_map.o differ diff --git a/srcs/so_long.h b/srcs/so_long.h index bc80180..56cc594 100644 --- a/srcs/so_long.h +++ b/srcs/so_long.h @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/13 16:30:59 by apommier #+# #+# */ -/* Updated: 2022/02/14 00:37:07 by apommier ### ########.fr */ +/* Updated: 2022/02/15 00:02:48 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -51,7 +51,7 @@ void check_arg(int argc, char **argv); //utils void ft_error(char *error_msg, char **map); int check_map(char **map); -void quit_game(t_data *img); +int quit_game(t_data *img); int key_press(int code, t_data *img); int *choose_bear(t_data *img); diff --git a/srcs/utils.c b/srcs/utils.c index 59604fe..9ef9eee 100644 --- a/srcs/utils.c +++ b/srcs/utils.c @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/13 23:37:02 by apommier #+# #+# */ -/* Updated: 2022/02/14 23:49:04 by apommier ### ########.fr */ +/* Updated: 2022/02/15 00:08:44 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,7 +41,7 @@ int check_map(char **map) return (1); } -void quit_game(t_data *img) +int quit_game(t_data *img) { int i; @@ -55,6 +55,7 @@ void quit_game(t_data *img) free(img->map_tab[i++]); free(img->map_tab); exit(1); + return (1); } int key_press(int code, t_data *img)