From: Dominik Kaiser Date: Thu, 9 May 2024 14:19:29 +0000 (+0200) Subject: Setup basic structure and add basic input handling X-Git-Url: https://git.dkaiser.de/?a=commitdiff_plain;h=8cec16bdb6f980565b29d5b55379e481018753f6;p=42%2Fso_long.git Setup basic structure and add basic input handling --- diff --git a/Makefile b/Makefile index 145fc8a..6315601 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LIBS = -Llibft -lft -lm -Lmlx -lmlx FRMWRKS = -framework OpenGL -framework AppKit VPATH := src -SRC = main.c +SRC = main.c init.c loop.c input.c OBJ_DIR := obj OBJ := $(addprefix $(OBJ_DIR)/, $(SRC:%.c=%.o)) diff --git a/include/so_long.h b/include/so_long.h index c1c966b..98b4711 100644 --- a/include/so_long.h +++ b/include/so_long.h @@ -6,13 +6,25 @@ /* By: dkaiser mlx, loop, game); + /* mlx_key_hook(game->mlx, on_key_down, game); */ + mlx_hook(game->window, 2, 0, on_key_down, game); + mlx_hook(game->window, 3, 0, on_key_up, game); +} + +int init(t_game *game) +{ + game->mlx = mlx_init(); + game->window = mlx_new_window(game->mlx, 1920, 1080, "so_long"); + // TODO: make size and title dynamic + init_hooks(game); + return (0); +} diff --git a/src/loop.c b/src/loop.c new file mode 100644 index 0000000..506dad1 --- /dev/null +++ b/src/loop.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* loop.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser