From 14ffe0479dc33cb5ed96f85535f84fa91d56c48b Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Thu, 9 May 2024 17:49:54 +0200 Subject: Add input to direction handling --- src/input.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/input.c (limited to 'src/input.c') diff --git a/src/input.c b/src/input.c new file mode 100644 index 0000000..2fcdc4e --- /dev/null +++ b/src/input.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* input.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser input_direction |= UP; + else if (keycode == 0) + game->input_direction |= LEFT; + else if (keycode == 1) + game->input_direction |= DOWN; + else if (keycode == 2) + game->input_direction |= RIGHT; + return (0); +} + +int on_key_up(int keycode, t_game *game) +{ + if (keycode == 13) + game->input_direction &= ~UP; + else if (keycode == 0) + game->input_direction &= ~LEFT; + else if (keycode == 1) + game->input_direction &= ~DOWN; + else if (keycode == 2) + game->input_direction &= ~RIGHT; + return (0); +} -- cgit v1.2.3