diff --git a/Makefile b/Makefile index 7598475..66d393d 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +SHELL = bash + NAME = cub3D CC = gcc @@ -14,12 +16,7 @@ MACRO_DIR = MacroLibX/ INCLUDE = -I $(I_DIR) -I $(LIBFT_DIR)/$(I_DIR) -I $(MACRO_DIR)/$(I_DIR) -SRCS = src/utils/mess_error.c \ - src/utils/parse_utils.c \ - src/parsing/check_map.c \ - src/parsing/check_arg.c \ - src/parsing/principal_pars.c \ - src/cub3d.c +SRCS = $(shell find src -name '*.c') OBJS = $(addprefix $(OBJSDIR), $(SRCS:.c=.o)) diff --git a/includes/game.h b/includes/game.h index 48e05e5..ccc1c7d 100644 --- a/includes/game.h +++ b/includes/game.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/11 16:38:40 by adjoly #+# #+# */ -/* Updated: 2024/09/11 17:06:22 by adjoly ### ########.fr */ +/* Updated: 2024/09/12 11:40:07 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,12 @@ typedef struct s_cub char **map; } t_cub; +#define ESCAPE_KEY 41 +#define W_KEY 26 +#define S_KEY 22 +#define A_KEY 4 +#define D_KEY 7 + /** * @brief This function is used to handle keypress * diff --git a/src/cub3d.c b/src/cub3d.c index 9b326ec..fd5c59c 100644 --- a/src/cub3d.c +++ b/src/cub3d.c @@ -6,20 +6,33 @@ /* By: madumerg +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/04 16:58:27 by madumerg #+# #+# */ -/* Updated: 2024/09/11 22:16:46 by madumerg ### ########.fr */ +/* Updated: 2024/09/12 11:22:31 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "cub3d.h" +#include "game.h" +#include "mlx.h" int main(int ac, char **av) { - char **map; + //char **map; - if (check_err_arg(ac, av) == 1) - return (1); - map = parse_map(av[1]); - if (verif_all_map(map) == 1) - return (1); + (void)ac; + (void)av; +// if (check_err_arg(ac, av) == 1) +// return (1); +// map = parse_map(av[1]); +// if (verif_all_map(map) == 1) +// return (1); + void *mlx = mlx_init(); + void *win = mlx_new_window(mlx, 400, 400, "WTF"); + + mlx_on_event(mlx, win, MLX_KEYDOWN, key_hook, mlx); + + mlx_loop(mlx); + + mlx_destroy_window(mlx, win); + mlx_destroy_display(mlx); return (0); } diff --git a/src/event_handler.c b/src/event_handler.c index b3bb0cd..c153eff 100644 --- a/src/event_handler.c +++ b/src/event_handler.c @@ -6,11 +6,26 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/11 16:37:56 by adjoly #+# #+# */ -/* Updated: 2024/09/11 16:38:17 by adjoly ### ########.fr */ +/* Updated: 2024/09/12 11:43:02 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ -int key_hook() +#include +#include "mlx.h" +#include "game.h" + +int key_hook(int key, void *mlx) { - + (void)mlx; + if (key == ESCAPE_KEY) + mlx_loop_end(mlx); + if (key == W_KEY) + printf("UP\n"); + if (key == S_KEY) + printf("DOWN\n"); + if (key == D_KEY) + printf("RIGHT\n"); + if (key == A_KEY) + printf("LEFT\n"); + return (0); }