aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-03 22:52:35 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-03 22:52:35 +0200
commitb92f5be51992760fec0fc110c46ea6cb15e962a8 (patch)
tree8b3282a61a4bfc53a4c975bb38524ad3cf2ea290
parentYES (diff)
download42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.tar.gz
42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.tar.bz2
42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.tar.xz
42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.tar.zst
42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.zip
Not quite done
-rw-r--r--inc/cub3d_defines.h2
-rw-r--r--map/lvl_five.cub2
-rw-r--r--src/ft_select_bad_boy_action.c33
3 files changed, 20 insertions, 17 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index ad16b57..74a228d 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -184,7 +184,7 @@ enum
# define FT_CHRST_MAP_ENTRY "0123456789NSEWLT!@+#e "
# define FT_CHRST_SPRITES "23456789"
# define FT_CHRST_SPAWN "NSEW"
-# define FT_CHRST_MAP_NON_WALL "023456789NESWLT!@+#e"
+# define FT_CHRST_MAP_NON_WALL "023456789NESWLT!@+#ex"
# define FT_CHRST_COLLISION "123456789e "
# define FT_CHRST_DETECT "1L"
# define FT_CHRST_ITEM "!@+#x"
diff --git a/map/lvl_five.cub b/map/lvl_five.cub
index 171005b..69e2039 100644
--- a/map/lvl_five.cub
+++ b/map/lvl_five.cub
@@ -27,7 +27,7 @@ MU ./media/sound/BITURE-ET-MELANCOLIE.wav
1e11101 101 1011101 101
11110000011111N1 101##@1 101
10110111111+1111 10111111101
- 101101 1L++11 1+000000001
+ 101101 1L#+11 1+000000001
100001 11+111111111111111101
101101 1111++++0000000000000e1
101101 1011111111111T011111101
diff --git a/src/ft_select_bad_boy_action.c b/src/ft_select_bad_boy_action.c
index 5a4f5be..3f3ca6f 100644
--- a/src/ft_select_bad_boy_action.c
+++ b/src/ft_select_bad_boy_action.c
@@ -94,13 +94,15 @@ int8_t
if (cl->sprites[13][id].s_pos_y > cl->plist.pos_y)
{
while (a2 < cl->sprites[13][id].s_pos_y - cl->plist.pos_y)
- a2 += 0.005;
+ a2 += 0.0005;
}
- else
+ else if (cl->sprites[13][id].s_pos_y < cl->plist.pos_y)
{
while (a2 < cl->plist.pos_y - cl->sprites[13][id].s_pos_y)
- a2 += 0.005;
+ a2 += 0.0005;
}
+ else
+ a2 = d;
if (a2 != d)
{
teta = acos(a2 / d);
@@ -113,18 +115,20 @@ int8_t
cl->rlist.y_ray_dir = 1;
cl->rlist.x_ray_dir = 1 * sin(teta);
}
+ if (cl->plist.pos_y > cl->sprites[13][id].s_pos_y)
+ cl->rlist.y_ray_dir = -cl->rlist.y_ray_dir;
if (cl->plist.pos_x > cl->sprites[13][id].s_pos_x)
cl->rlist.x_ray_dir = -cl->rlist.x_ray_dir;
hit = 0;
cl->rlist.y_ray_pos = cl->plist.pos_y;
cl->rlist.x_ray_pos = cl->plist.pos_x;
- cl->rlist.sqy = (uint64_t)cl->rlist.y_ray_pos;
- cl->rlist.sqx = (uint64_t)cl->rlist.x_ray_pos;
+ cl->rlist.sqy = lround(cl->rlist.y_ray_pos);
+ cl->rlist.sqx = lround(cl->rlist.x_ray_pos);
ft_detection_init_x(cl);
ft_detection_init_y(cl);
while (hit == 0 &&
- (cl->rlist.sqy != (uint64_t)cl->sprites[13][id].s_pos_y ||
- cl->rlist.sqx != (uint64_t)cl->sprites[13][id].s_pos_x))
+ (cl->rlist.sqy != (unsigned)lround(cl->sprites[13][id].s_pos_y) ||
+ cl->rlist.sqx != (unsigned)lround(cl->sprites[13][id].s_pos_x)))
{
if (cl->rlist.x_side_dist < cl->rlist.y_side_dist)
{
@@ -161,8 +165,7 @@ void
r = ft_set_r_ii();
ft_bb_act(r, i, cl);
}
- else if (cl->bad_boy[i].sleep == 0 && cl->bad_boy[i].life > 0 &&
- d > FT_ENMY_SIGHT_RANGE)
+ else if (cl->bad_boy[i].sleep == 0 && cl->bad_boy[i].life > 0)
{
r = ft_set_r_i();
ft_bb_act(r, i, cl);
@@ -173,16 +176,16 @@ void
ft_select_bad_boy_action(t_cub *cl)
{
int8_t i;
- double d;
+ /* double d; */
i = 0;
while (i < cl->mlist.sprite_nbr[13])
{
- if ((d = ft_get_dist(cl->sprites[13][i], cl))
- <= 4 * FT_ENMY_SIGHT_RANGE && cl->bad_boy[i].sleep == 0)
- {
- ft_select_action(i, d, cl);
- }
+ /* if ((d = ft_get_dist(cl->sprites[13][i], cl)) */
+ /* <= 4 * FT_ENMY_SIGHT_RANGE && cl->bad_boy[i].sleep == 0) */
+ /* { */
+ ft_select_action(i, ft_get_dist(cl->sprites[13][i], cl), cl);
+ /* } */
i++;
}
}