From 8cec16bdb6f980565b29d5b55379e481018753f6 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Thu, 9 May 2024 16:19:29 +0200 Subject: [PATCH] Setup basic structure and add basic input handling --- Makefile | 2 +- include/so_long.h | 18 +++++++++++++++--- src/init.c | 31 +++++++++++++++++++++++++++++++ src/loop.c | 18 ++++++++++++++++++ src/main.c | 10 +++++++--- 5 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 src/init.c create mode 100644 src/loop.c 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