aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-23 20:00:20 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-23 20:00:20 +0100
commitcc8c83d66e4cfa8f3660c7fbfefc15d3b5d7aa01 (patch)
tree36dac1a0a4a1aac6e41d731d4a5fb6f7c5f7a691 /src
parentAlmost there (diff)
download42-cub3d-cc8c83d66e4cfa8f3660c7fbfefc15d3b5d7aa01.tar.gz
42-cub3d-cc8c83d66e4cfa8f3660c7fbfefc15d3b5d7aa01.tar.bz2
42-cub3d-cc8c83d66e4cfa8f3660c7fbfefc15d3b5d7aa01.tar.xz
42-cub3d-cc8c83d66e4cfa8f3660c7fbfefc15d3b5d7aa01.tar.zst
42-cub3d-cc8c83d66e4cfa8f3660c7fbfefc15d3b5d7aa01.zip
This is great
Diffstat (limited to 'src')
-rw-r--r--src/ft_draw_textures.c6
-rw-r--r--src/ft_raycasting.c18
2 files changed, 12 insertions, 12 deletions
diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c
index c7684f9..56be3ee 100644
--- a/src/ft_draw_textures.c
+++ b/src/ft_draw_textures.c
@@ -30,11 +30,11 @@ void
if ((dist = cl->rlist.wall_dist_tab[x]) <= 0)
dist = 0.0001;
- rgb.r = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->tlist[cl->rlist.w_side_tab[x]].tex_x
+ rgb.r = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->rlist.tex_x_tab[x]
* 4 + 4 * cl->tlist[cl->rlist.w_side_tab[x]].img_h * tex_y + 2];
- rgb.g = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->tlist[cl->rlist.w_side_tab[x]].tex_x
+ rgb.g = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->rlist.tex_x_tab[x]
* 4 + 4 * cl->tlist[cl->rlist.w_side_tab[x]].img_h * tex_y + 1];
- rgb.b = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->tlist[cl->rlist.w_side_tab[x]].tex_x
+ rgb.b = (uint8_t)cl->tlist[cl->rlist.w_side_tab[x]].ptr[cl->rlist.tex_x_tab[x]
* 4 + 4 * cl->tlist[cl->rlist.w_side_tab[x]].img_h * tex_y];
*(int*)(cl->img.ptr + ((uint16_t)x * 4 +
(y * cl->img.sizeline))) = ft_rgb_to_hex(dist, rgb, cl);
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 3429f20..99fabeb 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -71,17 +71,17 @@ static void
{
ft_initray(i, cl);
cl->rlist.line_h = (int16_t)(wl->y_size / cl->rlist.wall_dist);
- cl->rlist.line_h_tab[i] = cl->rlist.line_h;
cl->rlist.wall_t = -cl->rlist.line_h / 2 + wl->y_size / 2;
if (cl->rlist.wall_t < 0)
cl->rlist.wall_t = 0;
- cl->rlist.wall_t_tab[i] = cl->rlist.wall_t;
cl->rlist.wall_b = cl->rlist.line_h / 2 + wl->y_size / 2;
if (cl->rlist.wall_b >= (int16_t)wl->y_size)
cl->rlist.wall_b = wl->y_size - 1;
- cl->rlist.wall_b_tab[i] = cl->rlist.wall_b;
ft_choose_tex(i, cl);
ft_calc_tex(cl);
+ cl->rlist.tex_x_tab[i] = cl->tlist[cl->w_side].tex_x;
+ cl->rlist.line_h_tab[i] = cl->rlist.line_h;
+ cl->rlist.wall_t_tab[i] = cl->rlist.wall_t;
cl->rlist.wall_bz[i] = cl->rlist.wall_b;
cl->rlist.wall_dist_tab[i] = cl->rlist.wall_dist;
}
@@ -97,10 +97,10 @@ void
if (!(cl->rlist.wall_bz =
(int16_t*)malloc(cl->wlist.x_size * sizeof(int16_t))))
return ;
- cl->rlist.w_side_tab = (uint8_t*)ft_calloc(cl->wlist.x_size, sizeof(uint8_t));
- cl->rlist.line_h_tab = (uint16_t*)ft_calloc(cl->wlist.x_size, sizeof(uint16_t));
- cl->rlist.wall_t_tab = (int16_t*)ft_calloc(cl->wlist.x_size, sizeof(int16_t));
- cl->rlist.wall_b_tab = (int16_t*)ft_calloc(cl->wlist.x_size, sizeof(int16_t));
+ cl->rlist.w_side_tab = (uint8_t*)malloc(cl->wlist.x_size * sizeof(uint8_t));
+ cl->rlist.line_h_tab = (uint16_t*)malloc(cl->wlist.x_size * sizeof(uint16_t));
+ cl->rlist.wall_t_tab = (int16_t*)malloc(cl->wlist.x_size * sizeof(int16_t));
+ cl->rlist.tex_x_tab = (int32_t*)malloc(cl->wlist.x_size * sizeof(int32_t));
i = 0;
while (i < cl->wlist.x_size)
{
@@ -110,7 +110,7 @@ void
i = 0;
while (i < cl->wlist.x_size)
{
- ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]);
+ ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_bz[i]);
i++;
}
ft_floor_cast(cl);
@@ -120,8 +120,8 @@ void
ft_calc_weaps(cl);
if (cl->plist.handles_weapon > -1)
ft_draw_handweap(cl);
+ ft_memdel((void*)&cl->rlist.tex_x_tab);
ft_memdel((void*)&cl->rlist.wall_t_tab);
- ft_memdel((void*)&cl->rlist.wall_b_tab);
ft_memdel((void*)&cl->rlist.w_side_tab);
ft_memdel((void*)&cl->rlist.line_h_tab);
ft_memdel((void*)&cl->rlist.wall_dist_tab);