@ -29,13 +29,16 @@ all: $(NAME)
$(VERBOSE).SILENT:
$(LIBFT):
echo "Downloading narnaud/libft and making library"
bash -c "if [[ ! -d "libft" ]]; then git clone \
https://git.narnaud.net/nicolas-arnaud/Libft.git libft; fi"
${MAKE} -C libft/
cp libft/libft.a lib/
cp libft/libft.h includes/
echo ✅
$(MLX):
echo "Downloading 42Paris/minilibx and making library"
bash -c "if [[ ! -d "mlx" ]]; then git clone \
https://github.com/42Paris/minilibx-linux.git mlx; fi"
${MAKE} -C mlx/
@ -46,6 +49,7 @@ ifeq ($(UNAME_S), Darwin)
cp mlx/libmlx.a lib/
endif
cp mlx/mlx.h includes/
$(NAME): $(LIBFT) $(MLX) $(OBJS)
echo Making Cub3D...
@ -114,6 +114,7 @@ int mouse_move_hook(int x, int y, t_env *env);
int mouse_up_hook(int buton, int x, int y, t_env *env);
int update_hook(t_env *env);
void init_window(t_env *nv);
int exit_game(t_env *env);
int init_game(t_env *env);
// Utils
@ -92,5 +92,6 @@ int init_game(t_env *env)
mlx_hook(env->win, 2, 1L << 0, key_press_hook, env);
mlx_hook(env->win, 3, 1L << 1, key_release_hook, env);
mlx_hook(env->win, 6, 0L, mouse_move_hook, env);
mlx_hook(env->win, 17, 0L, exit_game, env);
return (EXIT_SUCCESS);
}
@ -12,12 +12,18 @@
#include "../../includes/cub3d.h"
int exit_game(t_env *env)
{
(void)env;
exit(EXIT_SUCCESS);
int key_press_hook(int keycode, t_env *env)
if (keycode == KEY_M)
env->minimap = !env->minimap;
else if (keycode == KEY_ECHAP)
exit_game(env);
else
env->controls[keycode] = 1;
return (1);