aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_draw_textures.c18
-rw-r--r--src/ft_raycasting.c13
-rw-r--r--src/ft_tex_init.c19
3 files changed, 45 insertions, 5 deletions
diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c
index 321fd18..bb5a6e4 100644
--- a/src/ft_draw_textures.c
+++ b/src/ft_draw_textures.c
@@ -13,14 +13,22 @@
#include <cub3d.h>
#include <stdint.h>
+/*
+ * 0 : no
+ * 1 : so
+ * 2 : ea
+ * 3 : we
+ * 4 : sprite
+ **/
+
void ft_choose_tex(t_cub *clist)
{
- if (clist->rlist.side == 0 && clist->rlist.x_ray_direction > 0)
+ if (clist->rlist.side == 0 && clist->rlist.x_ray_dir < 0)
clist->w_side = 0;
- else if (clist->rlist.side == 0 && clist->rlist.x_ray_direction < 0)
- clist->w_side = 3;
- else if (clist->rlist.side == 1 && clist->rlist.y_ray_direction > 0)
+ else if (clist->rlist.side == 0 && clist->rlist.x_ray_dir > 0)
clist->w_side = 1;
- else (clist->rlist.side == 1 && clist->rlist.y_ray_direction < 0)
+ else if (clist->rlist.side == 1 && clist->rlist.y_ray_dir > 0)
clist->w_side = 2;
+ else
+ clist->w_side = 3;
}
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index a4446b3..7b03b84 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -12,6 +12,16 @@
#include <cub3d.h>
#include <stdint.h>
+#include <stdio.h>
+
+void
+ ft_calc_tex(t_cub *clist)
+{
+ if (clist->rlist.side == 1)
+ clist->rlist.wall_hit_x = clist->plist->pos_y + clist->rlist.wall_dist * clist->rlist.y_ray_dir;
+ else
+ clist->rlist.wall_hit_x = clist->plist->pos_x + clist->rlist.wall_dist * clist->rlist.x_ray_dir;
+}
static void
ft_initray(t_cub *cl, uint16_t i)
@@ -57,6 +67,9 @@ void
cl->rlist.wall_b = cl->rlist.line_h / 2 + wl->y_size / 2;
if (cl->rlist.wall_b >= wl->y_size)
cl->rlist.wall_b = wl->y_size - 1;
+ ft_choose_tex(cl);
+ ft_calc_tex(cl);
+ printf("%f\n", cl->rlist.wall_hit_x);
ft_draw_verline(cl, i, cl->rlist.wall_t - 1, cl->rlist.wall_b);
i++;
}
diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c
index aba5338..fc0a9dd 100644
--- a/src/ft_tex_init.c
+++ b/src/ft_tex_init.c
@@ -13,6 +13,8 @@
#include <cub3d.h>
#include <stdint.h>
#include <mlx.h>
+#include <stdio.h>
+#include <libft.h>
/*
* 0 : no
@@ -22,6 +24,22 @@
* 4 : sprite
**/
+void ft_puttex(t_cub *clist)
+{
+ int i;
+
+ i = 0;
+ while (i < clist->tlist[0].img_w)
+ {
+ printf("no : img : %p data : %s, height : %d i : %d\n", clist->tlist[0].img, clist->tlist[0].ptr + i, clist->tlist[0].img_w, i / 4);
+ i += 4;
+ }
+ printf("%d\n", clist->w_side);
+ /*printf("so : img : %p data : %x, height : %d\n", clist->tlist[1].img, (unsigned int)clist->tlist[1].ptr, clist->tlist[1].img_w);*/
+ /*printf("ea : img : %p data : %x, height : %d\n", clist->tlist[2].img, (unsigned int)clist->tlist[2].ptr, clist->tlist[2].img_w);*/
+ /*printf("we : img : %p data : %x, height : %d\n", clist->tlist[3].img, (unsigned int)clist->tlist[3].ptr, clist->tlist[3].img_w);*/
+}
+
void ft_wall_tex_init(t_cub *clist)
{
clist->tlist[0].img = mlx_xpm_file_to_image(clist->wlist->wlx,
@@ -44,4 +62,5 @@ void ft_wall_tex_init(t_cub *clist)
clist->mlist->sprite_path, &clist->tlist[4].img_w, &clist->tlist[4].img_h);
clist->tlist[4].ptr = mlx_get_data_addr(clist->tlist[4].img,
&clist->tlist[4].bpp, &clist->tlist[4].sizeline, &clist->tlist[4].endian);
+ ft_puttex(clist);
}