added keyrelease event

This commit is contained in:
Theo Champion 2025-07-09 17:12:10 +02:00
parent a58783350d
commit 3b495f213f

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */ /* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
/* Updated: 2025/07/09 17:07:29 by tchampio ### ########.fr */ /* Updated: 2025/07/09 17:09:01 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -79,6 +79,21 @@ int keypress_handler(int keycode, t_cub3d_data *data)
return (0); return (0);
} }
int keyrelease_handler(int keycode, t_cub3d_data *data)
{
if (keycode == XK_Escape)
destroy(data);
else if (keycode == XK_a)
data->player.movement.x = 0;
else if (keycode == XK_d)
data->player.movement.x = 0;
else if (keycode == XK_w)
data->player.movement.y = 0;
else if (keycode == XK_s)
data->player.movement.y = 0;
return (0);
}
void draw_map(t_mapdata *map, t_mlx_data *data) void draw_map(t_mapdata *map, t_mlx_data *data)
{ {
int i; int i;