manque render mur pas fixe

This commit is contained in:
Gregory Robledo 2024-10-17 18:04:40 +02:00
parent dee20e3897
commit fab7758283
3 changed files with 6 additions and 7 deletions

View file

@ -6,7 +6,7 @@
/* By: grobledo <grobledo@student.42.fr> +#+ +:+ +#+ */ /* By: grobledo <grobledo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/14 14:55:05 by greg #+# #+# */ /* 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; img_data[y * SCREEN_WIDTH + x] = COLOR_CEILING;
else if (y < draw_end) else if (y < draw_end)
{ {
tex_y = ((y - draw_start) * g_tex.tex_height) / line_height; tex_y = ((y - (-line_height / 2 + SCREEN_HEIGHT / 2)) * g_tex.tex_height) / line_height;
tex_x = (int)(g_ray.wallx * g_tex.tex_width); tex_x = (int)(g_ray.wallx * (double)g_tex.tex_width);
if (g_ray.side == 0 && g_ray.dir.x > 0) if (g_ray.side == 0 && g_ray.dir.x > 0)
tex_x = g_tex.tex_width - tex_x - 1; tex_x = g_tex.tex_width - tex_x - 1;
if (g_ray.side == 1 && g_ray.dir.y < 0) 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); 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]; 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;
// img_data[y * SCREEN_WIDTH + x] = COLOR_WALL;
} }
else else
img_data[y * SCREEN_WIDTH + x] = COLOR_FLOOR; img_data[y * SCREEN_WIDTH + x] = COLOR_FLOOR;

View file

@ -4,7 +4,7 @@ NO theimageforthenorthwall
C 0,2,67 C 0,2,67
SO SOUTH!!!!!!1 SO SOUTH!!!!!!1
WE weeeee WE weeeee
111 111111111
111110111 111110111
10000N001 10000N001
111110111 111110111

View file

@ -6,7 +6,7 @@
/* By: grobledo <grobledo@student.42.fr> +#+ +:+ +#+ */ /* By: grobledo <grobledo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/17 01:57:03 by greg #+# #+# */ /* 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */