/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* manage_keys.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/27 14:14:51 by erey-bet #+# #+# */ /* Updated: 2023/05/03 12:44:41 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ #include "game.h" int movement(t_ply *ply, int key) { if (key == MLX_KEY_W) ply->pos_y -= 0.1; else if (key == MLX_KEY_S) ply->pos_y += 0.1; else if (key == MLX_KEY_D) ply->pos_x += 0.1; else if (key == MLX_KEY_A) ply->pos_x -= 0.1; return (1); } int manage_keys(mlx_key_data_t keys, t_game *game) { int is_moving; is_moving = 0; if (keys.key == MLX_KEY_ESCAPE) mlx_close_window(game->mlx); else if (keys.key == MLX_KEY_W || keys.key == MLX_KEY_S || keys.key == MLX_KEY_D || keys.key == MLX_KEY_A) is_moving = movement(game->ply, keys.key); /*else if (key.key == MLX_KEY_RIGHT) game->ply->direc += 0.1; else if (key.key == MLX_KEY_LEFT) game->ply->direc -= 0.1;*/ if (is_moving) return (1); return (0); }