This commit is contained in:
ReverseSky 2024-10-17 12:28:34 +02:00
parent 571bf80c6e
commit a714e8110d

50
utils2.c Normal file
View file

@ -0,0 +1,50 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: greg <greg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}