diff options
Diffstat (limited to 'src/ft_basic_keys.c')
-rw-r--r-- | src/ft_basic_keys.c | 17 |
1 files changed, 12 insertions, 5 deletions
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); } |