summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-05-10 12:01:25 +0200
committerDominik Kaiser2024-05-10 12:01:25 +0200
commit546c596505ded408bd0a73343618b100013d310f (patch)
tree536765943fc7d0426fc54c08792a9572309ee7e2 /src/input.c
parent699a39ad492c6e7c5b7048378819d2ca8a98581f (diff)
downloadso_long-546c596505ded408bd0a73343618b100013d310f.tar.gz
so_long-546c596505ded408bd0a73343618b100013d310f.zip
Replicate main functionality in MLX42
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c18
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)