aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_floor_cast.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-09 01:52:21 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-09 01:52:21 +0100
commitc51419a68e38ed3a2eb28e740f72eaa436fbd106 (patch)
tree4cafa4ee075be34b32132c54fdda87c7ec996695 /src/ft_floor_cast.c
parentNigga my gun go off (diff)
download42-cub3d-c51419a68e38ed3a2eb28e740f72eaa436fbd106.tar.gz
42-cub3d-c51419a68e38ed3a2eb28e740f72eaa436fbd106.tar.bz2
42-cub3d-c51419a68e38ed3a2eb28e740f72eaa436fbd106.tar.xz
42-cub3d-c51419a68e38ed3a2eb28e740f72eaa436fbd106.tar.zst
42-cub3d-c51419a68e38ed3a2eb28e740f72eaa436fbd106.zip
Boy
Diffstat (limited to '')
-rw-r--r--src/ft_floor_cast.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index 6947403..1b22a71 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -13,18 +13,34 @@
#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_put_floor_tex(uint16_t y, uint16_t x, t_cub *cl)
+ ft_draw_extra_tex(uint8_t tid, uint16_t y, uint16_t x, t_cub *cl)
{
+ float dist;
+ float calc;
+
+ if ((dist = cl->rlist.row_dist) <= 0)
+ dist = 0.0001;
+ calc = (dist * 0.4);
+ calc = (calc >= 255) ? (255) : (calc);
+ calc = (calc < 1) ? (1) : (calc);
cl->img.ptr[x * 4 + (cl->img.sizeline * y)] =
- (uint8_t)cl->tlist[6].ptr[cl->tlist[6].tex_x * 4 + 4 *
- cl->tlist[6].img_h * cl->tlist[6].tex_y];
+ (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x * 4 + 4 *
+ cl->tlist[tid].img_h * cl->tlist[tid].tex_y] / calc;
cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 1] =
- (uint8_t)cl->tlist[6].ptr[cl->tlist[6].tex_x * 4 + 4 *
- cl->tlist[6].img_h * cl->tlist[6].tex_y + 1];
+ (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x * 4 + 4 *
+ cl->tlist[tid].img_h * cl->tlist[tid].tex_y + 1] / calc;
cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 2] =
- (uint8_t)cl->tlist[6].ptr[cl->tlist[6].tex_x * 4 + 4 *
- cl->tlist[6].img_h * cl->tlist[6].tex_y + 2];
+ (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x * 4 + 4 *
+ cl->tlist[tid].img_h * cl->tlist[tid].tex_y + 2] / calc;
cl->img.ptr[x * 4 + cl->wlist.x_size * y + 3] = (char)0;
}
@@ -37,9 +53,16 @@ static void
* (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);
rl->x_floor += cl->mlist.x_floor_step;
rl->y_floor += cl->mlist.y_floor_step;
- ft_put_floor_tex(y, x, cl);
+ 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); */
}
void