diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-02-02 20:29:00 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-02-02 20:29:00 +0100 |
commit | b7261229b7b83ebeae7384fd1a6d0cc3ee9eb50e (patch) | |
tree | 22581da209cf6e78c962eaeea4093f1156f706b1 /src/ft_key_events.c | |
parent | It moves (diff) | |
download | 42-cub3d-b7261229b7b83ebeae7384fd1a6d0cc3ee9eb50e.tar.gz 42-cub3d-b7261229b7b83ebeae7384fd1a6d0cc3ee9eb50e.tar.bz2 42-cub3d-b7261229b7b83ebeae7384fd1a6d0cc3ee9eb50e.tar.xz 42-cub3d-b7261229b7b83ebeae7384fd1a6d0cc3ee9eb50e.tar.zst 42-cub3d-b7261229b7b83ebeae7384fd1a6d0cc3ee9eb50e.zip |
Cool
Diffstat (limited to 'src/ft_key_events.c')
-rw-r--r-- | src/ft_key_events.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/ft_key_events.c b/src/ft_key_events.c index 697670c..0f3cbe2 100644 --- a/src/ft_key_events.c +++ b/src/ft_key_events.c @@ -18,8 +18,18 @@ static int ft_w_key(t_cub *clist) { + t_player *pl; + + pl = clist->plist; ft_printf("[W]\n"); - clist->plist->pos_y -= 1; + if (pl->view_side == 1) + pl->pos_y -= 1; + else if (pl->view_side == 2) + pl->pos_x += 1; + else if (pl->view_side == 3) + pl->pos_y += 1; + else if (pl->view_side == 4) + pl->pos_x -= 1; ft_drawmap(clist); return (0); } @@ -27,24 +37,45 @@ static int static int ft_a_key(t_cub *clist) { - (void)clist; + t_player *pl; + + pl = clist->plist; ft_printf("[A]\n"); + pl->view_side -= 1; + if (pl->view_side == 0) + pl->view_side = 4; return (0); } static int ft_s_key(t_cub *clist) { - (void)clist; + t_player *pl; + + pl = clist->plist; ft_printf("[S]\n"); + if (pl->view_side == 1) + pl->pos_y += 1; + else if (pl->view_side == 2) + pl->pos_x -= 1; + else if (pl->view_side == 3) + pl->pos_y -= 1; + else if (pl->view_side == 4) + pl->pos_x += 1; + ft_drawmap(clist); return (0); } static int ft_d_key(t_cub *clist) { - (void)clist; + t_player *pl; + + pl = clist->plist; ft_printf("[D]\n"); + pl->view_side += 1; + if (pl->view_side == 5) + pl->view_side = 1; return (0); } |