diff --git a/render.c b/render.c index b1e3958..cbcbc5c 100644 --- a/render.c +++ b/render.c @@ -6,7 +6,7 @@ /* By: grobledo +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/14 14:55:05 by greg #+# #+# */ -/* Updated: 2024/10/17 16:56:10 by grobledo ### ########.fr */ +/* Updated: 2024/10/17 18:02:06 by grobledo ### ########.fr */ /* */ /* ************************************************************************** */ @@ -148,16 +148,15 @@ static void draw_vertical_line(int x, u_int32_t *img_data) img_data[y * SCREEN_WIDTH + x] = COLOR_CEILING; else if (y < draw_end) { - tex_y = ((y - draw_start) * g_tex.tex_height) / line_height; - tex_x = (int)(g_ray.wallx * g_tex.tex_width); + tex_y = ((y - (-line_height / 2 + SCREEN_HEIGHT / 2)) * g_tex.tex_height) / line_height; + tex_x = (int)(g_ray.wallx * (double)g_tex.tex_width); if (g_ray.side == 0 && g_ray.dir.x > 0) tex_x = g_tex.tex_width - tex_x - 1; if (g_ray.side == 1 && g_ray.dir.y < 0) - tex_x = g_tex.tex_width - tex_x - 1; + tex_x = g_tex.tex_height - tex_x - 1; u_int32_t *texture_data = (u_int32_t *)mlx_get_data_addr(g_tex.textures[g_tex.tex_dir], &bpp, &size_line, &endian); color = texture_data[tex_x * g_tex.tex_width + tex_y]; img_data[y * SCREEN_WIDTH + x] = color; - // img_data[y * SCREEN_WIDTH + x] = COLOR_WALL; } else img_data[y * SCREEN_WIDTH + x] = COLOR_FLOOR; diff --git a/testmaps/good_directions.cub b/testmaps/good_directions.cub index 0701362..d27f00d 100644 --- a/testmaps/good_directions.cub +++ b/testmaps/good_directions.cub @@ -4,7 +4,7 @@ NO theimageforthenorthwall C 0,2,67 SO SOUTH!!!!!!1 WE weeeee - 111 +111111111 111110111 10000N001 111110111 diff --git a/utils2.c b/utils2.c index dc81ffa..9a323a8 100644 --- a/utils2.c +++ b/utils2.c @@ -6,7 +6,7 @@ /* By: grobledo +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/17 01:57:03 by greg #+# #+# */ -/* Updated: 2024/10/17 14:58:33 by grobledo ### ########.fr */ +/* Updated: 2024/10/17 17:39:18 by grobledo ### ########.fr */ /* */ /* ************************************************************************** */