diff options
Diffstat (limited to '')
-rw-r--r-- | inc/cub3d_structs.h | 1 | ||||
-rw-r--r-- | map/map_five.cub | 2 | ||||
-rw-r--r-- | src/ft_draw_verline.c | 2 | ||||
-rw-r--r-- | src/ft_raycasting.c | 6 |
4 files changed, 9 insertions, 2 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 7072628..995ef08 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -122,6 +122,7 @@ typedef struct s_ray { uint16_t line_h; float wall_dist; + float perp_wall_dist; float x_ray_pos; float y_ray_pos; float x_ray_dir; diff --git a/map/map_five.cub b/map/map_five.cub index 9d0f34f..39f1b22 100644 --- a/map/map_five.cub +++ b/map/map_five.cub @@ -17,7 +17,7 @@ L ./map/map_two.cub 1011000001110000000000000000L01 1001000000000000000000000000001 111111111011000001110000000000000000001 -10000000001100000111111111D111111111111 +100000000011000001111111111111111111111 11110111111111011100000010001 11110111111111010001010000001 11000000110101010000000000001 diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c index 8e71457..5368c4e 100644 --- a/src/ft_draw_verline.c +++ b/src/ft_draw_verline.c @@ -43,7 +43,7 @@ static void { curr_dist = cl->wlist.y_size / (2.0 * y - cl->wlist.y_size); weight = (curr_dist - dist_player) - / (cl->rlist.wall_dist - dist_player); + / (cl->rlist.perp_wall_dist - dist_player); curr_floor_x = weight * cl->rlist.floor_x_wall + (1.0 - weight) * cl->plist.pos_x; curr_floor_y = weight * cl->rlist.floor_y_wall diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 0a4b8b5..121e132 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -74,6 +74,12 @@ void else if (clist->rlist.side == 1 && clist->rlist.y_ray_dir < 0) clist->tlist[clist->w_side].tex_x = clist->tlist[clist->w_side].img_w - clist->tlist[clist->w_side].tex_x - 1; + if (clist->rlist.side == 0) + clist->rlist.perp_wall_dist = ((uint32_t)clist->plist.pos_x + - clist->plist.pos_x + (1 - clist->mlist.x_step) / 2) / clist->rlist.x_ray_dir; + else + clist->rlist.perp_wall_dist = ((uint32_t)clist->plist.pos_y + - clist->plist.pos_y + (1 - clist->mlist.y_step) / 2) / clist->rlist.y_ray_dir; } static void |