From 63fff28c5f73c833fdd6c5f1d0fa30dba150390a Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Fri, 14 Feb 2020 19:37:54 +0100 Subject: True [W][A][S][D] --- src/ft_basic_keys.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/ft_basic_keys.c') diff --git a/src/ft_basic_keys.c b/src/ft_basic_keys.c index 48fc009..d147486 100644 --- a/src/ft_basic_keys.c +++ b/src/ft_basic_keys.c @@ -17,10 +17,11 @@ int ft_w_key(t_cub *clist) { t_player *pl; + const float move_speed = 0.2; pl = clist->plist; - pl->pos_y += 0.2 * (-1); - pl->pos_x += 0; + pl->pos_y += move_speed * pl->dir_x; + pl->pos_x += move_speed * pl->dir_y; return (0); } @@ -28,9 +29,11 @@ int ft_a_key(t_cub *clist) { t_player *pl; + const float move_speed = 0.1; pl = clist->plist; - pl->pos_x -= 0.2; + pl->pos_y += move_speed * -pl->dir_y; + pl->pos_x += move_speed * pl->dir_x; return (0); } @@ -38,9 +41,11 @@ int ft_s_key(t_cub *clist) { t_player *pl; + const float move_speed = 0.2; pl = clist->plist; - pl->pos_y += 0.2; + pl->pos_y += move_speed * -pl->dir_x; + pl->pos_x += move_speed * -pl->dir_y; return (0); } @@ -48,8 +53,10 @@ int ft_d_key(t_cub *clist) { t_player *pl; + const float move_speed = 0.1; pl = clist->plist; - pl->pos_x += 0.2; + pl->pos_y += move_speed * pl->dir_y; + pl->pos_x += move_speed * -pl->dir_x; return (0); } -- cgit v1.2.3