aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-11 10:28:33 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-11 10:28:33 +0100
commit8df5ba15b4b54511ade9c875bf84ac2696630aa7 (patch)
tree211710fe8316324ab95257b945aafa16de70cec6
parentOk (diff)
download42-cub3d-8df5ba15b4b54511ade9c875bf84ac2696630aa7.tar.gz
42-cub3d-8df5ba15b4b54511ade9c875bf84ac2696630aa7.tar.bz2
42-cub3d-8df5ba15b4b54511ade9c875bf84ac2696630aa7.tar.xz
42-cub3d-8df5ba15b4b54511ade9c875bf84ac2696630aa7.tar.zst
42-cub3d-8df5ba15b4b54511ade9c875bf84ac2696630aa7.zip
Perfect collision on them traps
-rw-r--r--inc/cub3d_defines.h2
-rw-r--r--src/ft_key_loop.c7
2 files changed, 8 insertions, 1 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index 6453e73..6ab05c2 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -118,7 +118,7 @@ enum
# define FT_CHRST_MAP_ENTRY "012NSEWLT "
# define FT_CHRST_SPAWN "NSEW"
# define FT_CHRST_MAP_NON_WALL "02NESWLT"
-# define FT_CHRST_COLLISION "12T "
+# define FT_CHRST_COLLISION "12 "
# define FT_CHRST_DETECT "1L"
/*
diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c
index c68b228..d19daaa 100644
--- a/src/ft_key_loop.c
+++ b/src/ft_key_loop.c
@@ -54,6 +54,13 @@ static void
pl = &cl->plist;
x = ft_find_x(key, pl);
y = ft_find_y(key, pl);
+ if (cl->mlist.map[y][x] == 'T')
+ {
+ pl->pos_x = old_x + ((old_x - x) / 4);
+ pl->pos_y = old_y + ((old_y - y) / 4);
+ x = ft_find_x(key, pl);
+ y = ft_find_y(key, pl);
+ }
if (ft_ischarset(FT_CHRST_COLLISION, cl->mlist.map[(uint64_t)old_y][x]) ||
cl->mlist.map[(uint64_t)old_y][x] == '\0')
pl->pos_x = old_x;