aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-17 16:47:59 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-17 16:47:59 +0100
commit5c908cdcd9c09ee4e5656ddc62ca1153f630354a (patch)
treef9efc3e226ca87904cab92716c65b051b11c304d /src
parentRemoved "vim" map (diff)
parentsmall but important changes (diff)
download42-cub3d-5c908cdcd9c09ee4e5656ddc62ca1153f630354a.tar.gz
42-cub3d-5c908cdcd9c09ee4e5656ddc62ca1153f630354a.tar.bz2
42-cub3d-5c908cdcd9c09ee4e5656ddc62ca1153f630354a.tar.xz
42-cub3d-5c908cdcd9c09ee4e5656ddc62ca1153f630354a.tar.zst
42-cub3d-5c908cdcd9c09ee4e5656ddc62ca1153f630354a.zip
Merge branch 'tex_fmoen' of gitlab.com into tex_fmoen
Diffstat (limited to 'src')
-rw-r--r--src/ft_draw_textures.c25
-rw-r--r--src/ft_draw_verline.c1
-rw-r--r--src/ft_raycasting.c13
-rw-r--r--src/ft_tex_init.c19
4 files changed, 50 insertions, 8 deletions
diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c
index 36cc832..bb5a6e4 100644
--- a/src/ft_draw_textures.c
+++ b/src/ft_draw_textures.c
@@ -13,13 +13,22 @@
#include <cub3d.h>
#include <stdint.h>
-void ft_draw_wall(t_cub *clist, int x, int draw_start, int draw_end)
+/*
+ * 0 : no
+ * 1 : so
+ * 2 : ea
+ * 3 : we
+ * 4 : sprite
+ **/
+
+void ft_choose_tex(t_cub *clist)
{
- clist->img.ptr[/*calcul a la con*/x];
- /*
- * faire calcul wola
- *
- *
- *
- */
+ 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_dir > 0)
+ clist->w_side = 1;
+ 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_draw_verline.c b/src/ft_draw_verline.c
index 5c5ed29..bcddbc7 100644
--- a/src/ft_draw_verline.c
+++ b/src/ft_draw_verline.c
@@ -57,6 +57,7 @@ int8_t
}
y = y1;
ft_draw_ceil(cl, y, x);
+ ft_choose_tex(cl);
while (y <= y2)
{
*(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = 0x0000ffaa;
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index bf33374..90f6d88 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 >= (float)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);
}