diff options
author | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-09 19:23:39 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-09 19:23:39 +0100 |
commit | 5e4785ebcd1d67ecd3f3458ce0ed6107d1d7c7ec (patch) | |
tree | 3f5f57b872bce0fb7e4e2d7a8884dfb005b6e6dd /src/ft_key_events.c | |
parent | Secured a segfault (diff) | |
download | 42-cub3d-5e4785ebcd1d67ecd3f3458ce0ed6107d1d7c7ec.tar.gz 42-cub3d-5e4785ebcd1d67ecd3f3458ce0ed6107d1d7c7ec.tar.bz2 42-cub3d-5e4785ebcd1d67ecd3f3458ce0ed6107d1d7c7ec.tar.xz 42-cub3d-5e4785ebcd1d67ecd3f3458ce0ed6107d1d7c7ec.tar.zst 42-cub3d-5e4785ebcd1d67ecd3f3458ce0ed6107d1d7c7ec.zip |
Secured sides with w key
Diffstat (limited to 'src/ft_key_events.c')
-rw-r--r-- | src/ft_key_events.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/ft_key_events.c b/src/ft_key_events.c index 4e82aa5..199f254 100644 --- a/src/ft_key_events.c +++ b/src/ft_key_events.c @@ -15,7 +15,6 @@ #include <cub3d.h> #include <stdlib.h> -#include <stdio.h> static int ft_w_key(t_cub *clist) { @@ -24,23 +23,24 @@ static int pl = clist->plist; if (pl->view_side == 1) { - if (pl->pos_y <= 0.3) - pl->pos_y = pl->pos_y; - else - pl->pos_y -= 0.3; + if ((pl->pos_y -= 0.3) < 0.4) + pl->pos_y = 0.4; } else if (pl->view_side == 2) - pl->pos_x += 0.3; + { + if ((pl->pos_x += 0.3) > clist->map_w - 0.4) + pl->pos_x = clist->map_w - 0.4; + } else if (pl->view_side == 3) { - if (pl->pos_y >= 13.7) - pl->pos_y = pl->pos_y; - else - 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 == 4) - pl->pos_x -= 0.3; - printf("PosX> %f\nPosY> %f\n", pl->pos_x, pl->pos_y); + { + if ((pl->pos_x -= 0.3) < 0.4) + pl->pos_x = 0.4; + } ft_drawmap(clist); return (0); } |