diff options
| author | Dominik Kaiser | 2024-05-09 16:19:29 +0200 |
|---|---|---|
| committer | Dominik Kaiser | 2024-05-09 16:19:29 +0200 |
| commit | 8cec16bdb6f980565b29d5b55379e481018753f6 (patch) | |
| tree | 44749e569e77339b4830c979572563bb88d3c9dd /src | |
| parent | 7b7f18ebf7636b656788d8f0bfea5ab2662fd8dc (diff) | |
| download | so_long-8cec16bdb6f980565b29d5b55379e481018753f6.tar.gz so_long-8cec16bdb6f980565b29d5b55379e481018753f6.zip | |
Setup basic structure and add basic input handling
Diffstat (limited to 'src')
| -rw-r--r-- | src/init.c | 31 | ||||
| -rw-r--r-- | src/loop.c | 18 | ||||
| -rw-r--r-- | src/main.c | 10 |
3 files changed, 56 insertions, 3 deletions
diff --git a/src/init.c b/src/init.c new file mode 100644 index 0000000..569bed8 --- /dev/null +++ b/src/init.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* init.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/09 14:50:09 by dkaiser #+# #+# */ +/* Updated: 2024/05/09 16:13:22 by dkaiser ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "mlx.h" +#include "so_long.h" + +static void init_hooks(t_game *game) +{ + mlx_loop_hook(game->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 <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/09 15:09:24 by dkaiser #+# #+# */ +/* Updated: 2024/05/09 15:10:15 by dkaiser ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "so_long.h" + +int loop(t_game *game) +{ + return (0); +} @@ -6,13 +6,17 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/08 14:14:13 by dkaiser #+# #+# */ -/* Updated: 2024/05/08 15:56:23 by dkaiser ### ########.fr */ +/* Updated: 2024/05/09 15:15:29 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ +#include "mlx.h" #include "so_long.h" -int main(void) { +int main(void) +{ + t_game game; - return 0; + init(&game); + mlx_loop(game.mlx); } |
