From 246c9efc7d48342e8ed65340fcd08a97611e6da1 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Sun, 9 Feb 2020 19:27:16 +0100 Subject: Secured sides with S key --- src/ft_key_events.c | 20 ++++++++++++++++---- 1 file changed, 16 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 199f254..d400684 100644 --- a/src/ft_key_events.c +++ b/src/ft_key_events.c @@ -64,13 +64,25 @@ static int pl = clist->plist; if (pl->view_side == 1) - pl->pos_y += 0.3; + { + if ((pl->pos_y += 0.3) > clist->map_h - 0.4) + pl->pos_y = clist->map_h - 0.4; + } else if (pl->view_side == 2) - pl->pos_x -= 0.3; + { + if ((pl->pos_x -= 0.3) < 0.4) + pl->pos_x = 0.4; + } else if (pl->view_side == 3) - pl->pos_y -= 0.3; + { + if ((pl->pos_y -= 0.3) < 0.4) + pl->pos_y = 0.4; + } else if (pl->view_side == 4) - pl->pos_x += 0.3; + { + if ((pl->pos_x += 0.3) > clist->map_w - 0.4) + pl->pos_x = clist->map_w - 0.4; + } ft_drawmap(clist); return (0); } -- cgit v1.2.3