diff options
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); } |