From b7261229b7b83ebeae7384fd1a6d0cc3ee9eb50e Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Sun, 2 Feb 2020 20:29:00 +0100 Subject: Cool --- src/ft_key_events.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'src/ft_key_events.c') 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); } -- cgit v1.2.3