aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_floor_cast.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-09 02:11:22 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-09 02:11:31 +0100
commit40108b83398240f50c6045bfb2bf114bded43c72 (patch)
tree61e0e483e31e17724b2dd7e1a70088659e5be1bd /src/ft_floor_cast.c
parentBoy (diff)
download42-cub3d-40108b83398240f50c6045bfb2bf114bded43c72.tar.gz
42-cub3d-40108b83398240f50c6045bfb2bf114bded43c72.tar.bz2
42-cub3d-40108b83398240f50c6045bfb2bf114bded43c72.tar.xz
42-cub3d-40108b83398240f50c6045bfb2bf114bded43c72.tar.zst
42-cub3d-40108b83398240f50c6045bfb2bf114bded43c72.zip
Reparse, may not compile
Diffstat (limited to '')
-rw-r--r--src/ft_floor_cast.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index 1b22a71..de53666 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -13,13 +13,13 @@
#include <cub3d.h>
#include <stdint.h>
-/* static void */
-/* ft_draw_plain_horizontal(t_rgb rgb, t_cub *cl, int32_t y, int32_t x) */
-/* { */
-/* *(int*)(cl->img.ptr + */
-/* (x * 4 + (y * cl->img.sizeline))) */
-/* = ft_darken(rgb, cl); */
-/* } */
+static void
+ ft_draw_plain_horizontal(t_rgb rgb, t_cub *cl, int32_t y, int32_t x)
+{
+ *(int*)(cl->img.ptr +
+ (x * 4 + (y * cl->img.sizeline)))
+ = ft_darken(rgb, cl);
+}
static void
ft_draw_extra_tex(uint8_t tid, uint16_t y, uint16_t x, t_cub *cl)
@@ -45,24 +45,37 @@ static void
}
static void
+ ft_set_tex_xy(uint8_t tid, t_ray *rl, t_cub *cl)
+{
+ cl->tlist[tid].tex_y = (int32_t)(cl->tlist[tid].img_w
+ * (rl->x_floor - rl->x_cell)) % (cl->tlist[tid].img_w);
+ cl->tlist[tid].tex_x = (int32_t)(cl->tlist[tid].img_h
+ * (rl->y_floor - rl->y_cell)) % (cl->tlist[tid].img_h);
+}
+
+static void
ft_floor_cast_loop(uint16_t y, uint16_t x, t_ray *rl, t_cub *cl)
{
rl->x_cell = (int32_t)(rl->x_floor);
rl->y_cell = (int32_t)(rl->y_floor);
- cl->tlist[6].tex_y = (int32_t)(cl->tlist[6].img_w
- * (rl->x_floor - rl->x_cell)) % (cl->tlist[6].img_w);
- cl->tlist[6].tex_x = (int32_t)(cl->tlist[6].img_h
- * (rl->y_floor - rl->y_cell)) % (cl->tlist[6].img_h);
- cl->tlist[7].tex_y = (int32_t)(cl->tlist[7].img_w
- * (rl->x_floor - rl->x_cell)) % (cl->tlist[7].img_w);
- cl->tlist[7].tex_x = (int32_t)(cl->tlist[7].img_h
- * (rl->y_floor - rl->y_cell)) % (cl->tlist[7].img_h);
+ if (cl->mlist.isftex)
+ {
+ ft_set_tex_xy(6, rl, cl);
+ }
+ if (cl->mlist.isctex)
+ {
+ ft_set_tex_xy(7, rl, cl);
+ }
rl->x_floor += cl->mlist.x_floor_step;
rl->y_floor += cl->mlist.y_floor_step;
- ft_draw_extra_tex(6, y, x, cl);
- ft_draw_extra_tex(7, cl->wlist.y_size - y - 1, x, cl);
- /* ft_draw_plain_horizontal(cl->f_rgb, cl, y, x); */
- /* ft_draw_plain_horizontal(cl->c_rgb, cl, cl->wlist.y_size - y - 1, x); */
+ if (cl->mlist.isftex)
+ ft_draw_extra_tex(6, y, x, cl);
+ else
+ ft_draw_plain_horizontal(cl->f_rgb, cl, y, x);
+ if (cl->mlist.isctex)
+ ft_draw_extra_tex(7, cl->wlist.y_size - y - 1, x, cl);
+ else
+ ft_draw_plain_horizontal(cl->c_rgb, cl, cl->wlist.y_size - y - 1, x);
}
void