added movement vector movement core

This commit is contained in:
Theo Champion 2025-07-09 17:08:01 +02:00
parent ba42e0d3e1
commit a58783350d
3 changed files with 23 additions and 16 deletions

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
/* Updated: 2025/07/09 16:23:50 by tchampio ### ########.fr */
/* Updated: 2025/07/09 17:07:29 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,7 @@
#include "../includes/structs.h"
#include "../mlx/mlx.h"
#include "../includes/maputils.h"
#include "../includes/cub3d_consts.h"
#include <stdbool.h>
#include <X11/keysym.h>
#include <X11/X.h>
@ -67,8 +68,14 @@ int keypress_handler(int keycode, t_cub3d_data *data)
{
if (keycode == XK_Escape)
destroy(data);
else if (keycode == XK_w || keycode == XK_a || keycode == XK_s || keycode == XK_d)
ft_printf("salut\n");
else if (keycode == XK_a)
data->player.movement.x = -MOVEMENT_SPEED;
else if (keycode == XK_d)
data->player.movement.x = MOVEMENT_SPEED;
else if (keycode == XK_w)
data->player.movement.y = -MOVEMENT_SPEED;
else if (keycode == XK_s)
data->player.movement.y = MOVEMENT_SPEED;
return (0);
}