aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-09 19:27:16 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-09 19:27:16 +0100
commit246c9efc7d48342e8ed65340fcd08a97611e6da1 (patch)
tree18382f712a11a165296c737ddd5e3d76e76da187 /src
parentSecured sides with w key (diff)
download42-cub3d-246c9efc7d48342e8ed65340fcd08a97611e6da1.tar.gz
42-cub3d-246c9efc7d48342e8ed65340fcd08a97611e6da1.tar.bz2
42-cub3d-246c9efc7d48342e8ed65340fcd08a97611e6da1.tar.xz
42-cub3d-246c9efc7d48342e8ed65340fcd08a97611e6da1.tar.zst
42-cub3d-246c9efc7d48342e8ed65340fcd08a97611e6da1.zip
Secured sides with S key
Diffstat (limited to 'src')
-rw-r--r--src/ft_key_events.c20
1 files changed, 16 insertions, 4 deletions
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);
}