aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_basic_keys.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p1.le-101.fr>2020-02-14 19:37:54 +0100
committerRudy Bousset <rbousset@z2r4p1.le-101.fr>2020-02-14 19:37:54 +0100
commit63fff28c5f73c833fdd6c5f1d0fa30dba150390a (patch)
treef4617aed38d9f2127949b323a7f032efcb5d5f3b /src/ft_basic_keys.c
parentChanged rotspeed again (diff)
download42-cub3d-63fff28c5f73c833fdd6c5f1d0fa30dba150390a.tar.gz
42-cub3d-63fff28c5f73c833fdd6c5f1d0fa30dba150390a.tar.bz2
42-cub3d-63fff28c5f73c833fdd6c5f1d0fa30dba150390a.tar.xz
42-cub3d-63fff28c5f73c833fdd6c5f1d0fa30dba150390a.tar.zst
42-cub3d-63fff28c5f73c833fdd6c5f1d0fa30dba150390a.zip
True [W][A][S][D]
Diffstat (limited to 'src/ft_basic_keys.c')
-rw-r--r--src/ft_basic_keys.c17
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);
}