diff options
author | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-09 18:49:09 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-09 18:49:09 +0100 |
commit | a096f3bc44d6df06b752e148a8cf33d9099700d1 (patch) | |
tree | 0f44433e4602f2534689a9313e830a6076f01055 /src | |
parent | Screenres ok (diff) | |
download | 42-cub3d-a096f3bc44d6df06b752e148a8cf33d9099700d1.tar.gz 42-cub3d-a096f3bc44d6df06b752e148a8cf33d9099700d1.tar.bz2 42-cub3d-a096f3bc44d6df06b752e148a8cf33d9099700d1.tar.xz 42-cub3d-a096f3bc44d6df06b752e148a8cf33d9099700d1.tar.zst 42-cub3d-a096f3bc44d6df06b752e148a8cf33d9099700d1.zip |
Secured a segfault
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_key_events.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ft_key_events.c b/src/ft_key_events.c index 7955dc6..4e82aa5 100644 --- a/src/ft_key_events.c +++ b/src/ft_key_events.c @@ -23,11 +23,21 @@ static int pl = clist->plist; if (pl->view_side == 1) - pl->pos_y -= 0.3; + { + if (pl->pos_y <= 0.3) + pl->pos_y = pl->pos_y; + else + pl->pos_y -= 0.3; + } else if (pl->view_side == 2) pl->pos_x += 0.3; else if (pl->view_side == 3) - pl->pos_y += 0.3; + { + if (pl->pos_y >= 13.7) + pl->pos_y = pl->pos_y; + else + pl->pos_y += 0.3; + } else if (pl->view_side == 4) pl->pos_x -= 0.3; printf("PosX> %f\nPosY> %f\n", pl->pos_x, pl->pos_y); |