done
This commit is contained in:
parent
8d0ee0aed9
commit
4a58e0bef2
6
Makefile
6
Makefile
@ -6,7 +6,7 @@
|
||||
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2022/02/13 16:27:49 by apommier #+# #+# #
|
||||
# Updated: 2022/02/13 23:53:19 by apommier ### ########.fr #
|
||||
# Updated: 2022/02/14 23:44:46 by apommier ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -16,9 +16,9 @@ SRCS = srcs/main.c\
|
||||
srcs/utils.c\
|
||||
srcs/print_map.c
|
||||
OBJS = ${SRCS:.c=.o}
|
||||
CC = gcc
|
||||
CC = gcc
|
||||
LIB = -L ./mlx -lmlx -lXext -lX11
|
||||
CFLAGS = -Wall -Wextra -Werror
|
||||
CFLAGS = -g -Wall -Wextra
|
||||
RM = rm -rf
|
||||
LIBFT = ./libft
|
||||
|
||||
|
||||
30
srcs/main.c
30
srcs/main.c
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/02/13 16:42:55 by apommier #+# #+# */
|
||||
/* Updated: 2022/02/14 00:54:18 by apommier ### ########.fr */
|
||||
/* Updated: 2022/02/14 23:49:53 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -118,6 +118,27 @@ 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;
|
||||
@ -134,10 +155,15 @@ int main(int argc, char **argv)
|
||||
check_map(img.map_tab);
|
||||
img.mlx = mlx_init();
|
||||
if (!img.mlx)
|
||||
free_double(img.map_tab);
|
||||
ft_error("Error: mlx_init fail", img.map_tab);
|
||||
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_loop(img.mlx);
|
||||
}
|
||||
|
||||
BIN
srcs/main.o
Normal file
BIN
srcs/main.o
Normal file
Binary file not shown.
BIN
srcs/parsing.o
Normal file
BIN
srcs/parsing.o
Normal file
Binary file not shown.
BIN
srcs/print_map.o
Normal file
BIN
srcs/print_map.o
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/02/13 23:37:02 by apommier #+# #+# */
|
||||
/* Updated: 2022/02/14 00:39:41 by apommier ### ########.fr */
|
||||
/* Updated: 2022/02/14 23:49:04 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -46,7 +46,7 @@ void quit_game(t_data *img)
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
mlx_clear_window(img->mlx, img->mlx_win);
|
||||
printf("img = %p\n", img);
|
||||
mlx_destroy_window(img->mlx, img->mlx_win);
|
||||
mlx_destroy_display(img->mlx);
|
||||
if (img->mlx)
|
||||
|
||||
BIN
srcs/utils.o
Normal file
BIN
srcs/utils.o
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user