diff options
Diffstat (limited to 'src/input.c')
| -rw-r--r-- | src/input.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/input.c b/src/input.c index fe1f219..7582226 100644 --- a/src/input.c +++ b/src/input.c @@ -6,14 +6,27 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/09 15:37:40 by dkaiser #+# #+# */ -/* Updated: 2024/05/09 19:32:18 by dkaiser ### ########.fr */ +/* Updated: 2024/05/10 11:33:09 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ #include "so_long.h" -int on_key_down(int keycode, t_game *game) +void on_key_down(mlx_key_data_t keydata, void *params) { + t_game *game; + int keycode; + + keycode = keydata.os_key; + + game = (t_game *) params; + + if (keydata.action == MLX_RELEASE) + { + on_key_up(keycode, game); + return; + } + if (keycode == 13 || keycode == 126) game->input_direction |= UP; else if (keycode == 0 || keycode == 123) @@ -22,7 +35,6 @@ int on_key_down(int keycode, t_game *game) game->input_direction |= DOWN; else if (keycode == 2 || keycode == 124) game->input_direction |= RIGHT; - return (0); } int on_key_up(int keycode, t_game *game) |
