diff --git a/utils2.c b/utils2.c new file mode 100644 index 0000000..6e3d3b3 --- /dev/null +++ b/utils2.c @@ -0,0 +1,50 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* utils2.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: greg +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/17 01:57:03 by greg #+# #+# */ +/* Updated: 2024/10/17 12:28:01 by greg ### ########.fr */ +/* */ +/* ************************************************************************** */ + +// #include "algo.h" +void ft_init_texture() +{ + if (ray.side == 0 && ray.raydirx < 0) + direction = 0; + if (ray.side == 0 && ray.raydirx >= 0) + direction = 1; + if (ray.side == 1 && ray.raydiry < 0) + direction = 2; + if (ray.side == 1 && ray.raydiry >= 0) + direction = 3; + if (ray.side == 0) + t.wallx = ray.posy + ray.perpwalldist \ + * ray.raydiry; + else + t.wallx = ray.posx + ray.perpwalldist \ + * ray.raydirx; + t.wallx -= floor((t.wallx)); +} + +texture[0].addr = (int *)mlx_get_data_addr(texture[0].img, &bpp, + texture[0].line_length, &endian); + + +void load_textures() +{ + g_tex.tex_width = 64; + g_tex.tex_height = 64; + + g_tex.textures[0] = mlx_xpm_file_to_image(g_mlx, "textures/north.xpm", + &g_tex.tex_width, &g_tex.tex_height); + g_tex.textures[1] = mlx_xpm_file_to_image(g_mlx, "textures/south.xpm", + &g_tex.tex_width, &g_tex.tex_height); + g_tex.textures[2]= mlx_xpm_file_to_image(g_mlx, "textures/east.xpm", + &g_tex.tex_width, &g_tex.tex_height); + g_tex.textures[3]= mlx_xpm_file_to_image(g_mlx, "textures/west.xpm", + &g_tex.tex_width, &g_tex.tex_height); +} \ No newline at end of file