aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d.h2
-rw-r--r--src/ft_darken_rgb.c32
-rw-r--r--src/ft_draw_verline.c63
-rw-r--r--src/ft_floor_cast.c34
-rw-r--r--src/ft_raycasting.c2
5 files changed, 32 insertions, 101 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index e97af59..7014e51 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -138,6 +138,6 @@ int ft_exit(uint8_t exit_code, t_cub *clist);
uint32_t ft_rgb_to_hex(t_rgb rgb);
t_bmp_rgb ft_hex_to_rgb(uint32_t color);
uint32_t ft_darken_ceil(t_rgb rgb, int32_t y, t_cub *cl);
-uint32_t ft_darken_floor(t_rgb rgb, float dist, t_cub *cl);
+uint32_t ft_darken_floor(t_rgb rgb, int32_t y, t_cub *cl);
# endif
diff --git a/src/ft_darken_rgb.c b/src/ft_darken_rgb.c
index 434fcf8..656aac7 100644
--- a/src/ft_darken_rgb.c
+++ b/src/ft_darken_rgb.c
@@ -29,22 +29,18 @@ uint32_t
return (ft_rgb_to_hex(darker));
}
-uint32_t
- ft_darken_floor(t_rgb rgb, float dist, t_cub *cl)
-{
- t_rgb darker;
- float calc;
+/* uint32_t */
+/* ft_darken_floor(t_rgb rgb, int32_t y, t_cub *cl) */
+/* { */
+/* t_rgb darker; */
+/* float calc; */
- /* calc = ((float)(y + (75000.0 / cl->wlist.y_size)) */
- /* / (cl->wlist.y_size / 2)) - 1.0; */
- /* calc = (calc < 0) ? (0) : (calc); */
- (void)cl;
- calc = (dist * 0.4);
- calc = (calc >= 255) ? (255) : (calc);
- calc = (calc < 1) ? (1) : (calc);
- darker = rgb;
- darker.r *= calc;
- darker.g *= calc;
- darker.b *= calc;
- return (ft_rgb_to_hex(darker));
-}
+/* calc = ((float)(y + (75000.0 / cl->wlist.y_size)) */
+/* / (cl->wlist.y_size / 2)) - 1.0; */
+/* calc = (calc < 0) ? (0) : (calc); */
+/* darker = rgb; */
+/* darker.r *= calc; */
+/* darker.g *= calc; */
+/* darker.b *= calc; */
+/* return (ft_rgb_to_hex(darker)); */
+/* } */
diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c
index 7f0fd1c..b6729de 100644
--- a/src/ft_draw_verline.c
+++ b/src/ft_draw_verline.c
@@ -13,56 +13,17 @@
#include <cub3d.h>
#include <stdint.h>
-static void
- ft_draw_floor_tex(t_cub *cl, int32_t y, int32_t x, int32_t tex_y)
-{
- 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 * tex_y];
- 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 * tex_y + 1];
- 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 * tex_y + 2];
- cl->img.ptr[x * 4 + cl->wlist.x_size * y + 3] = (int8_t)0;
-}
-
-#include <stdio.h>
-static void
- ft_draw_floor(t_cub *cl, int32_t y, int32_t x)
-{
- float dist_player;
- float curr_dist;
- float weight;
- float curr_floor_x;
- float curr_floor_y;
-
- dist_player = 0.0;
- while ((uint32_t)y < cl->wlist.y_size)
- {
- curr_dist = cl->wlist.y_size / (2.0 * y - cl->wlist.y_size);
- weight = (curr_dist - dist_player)
- / (cl->rlist.wall_dist - dist_player);
- curr_floor_x = weight * cl->rlist.floor_x_wall
- + (1.0 - weight) * cl->plist.pos_x;
- curr_floor_y = weight * cl->rlist.floor_y_wall
- + (1.0 - weight) * cl->plist.pos_y;
- cl->tlist[6].tex_x = (int32_t)(curr_floor_x * cl->tlist[6].img_w)
- % cl->tlist[6].img_w;
- cl->tlist[6].tex_y = (int32_t)(curr_floor_y * cl->tlist[6].img_h)
- % cl->tlist[6].img_h;
- /* cl->tlist[6].tex_x = (cl->tlist[6].tex_x > 0) */
- /* ? (cl->tlist[6].tex_x) : (-cl->tlist[6].tex_x); */
- /* cl->tlist[6].tex_y = (cl->tlist[6].tex_y > 0) */
- /* ? (cl->tlist[6].tex_y) : (-cl->tlist[6].tex_y); */
- ft_draw_floor_tex(cl, y, x, cl->tlist[6].tex_y);
- /* *(int*)(cl->img.ptr + */
- /* (x * 4 + (y * cl->img.sizeline))) */
- /* = ft_darken_floor(cl->f_rgb, weight, cl); */
- y++;
- }
-}
+/* static void */
+/* ft_draw_floor(t_cub *cl, int32_t y, int32_t x) */
+/* { */
+/* while ((uint32_t)y < cl->wlist.y_size) */
+/* { */
+/* *(int*)(cl->img.ptr + */
+/* (x * 4 + (y * cl->img.sizeline))) */
+/* = ft_darken_floor(cl->f_rgb, y, cl); */
+/* y++; */
+/* } */
+/* } */
static void
ft_draw_ceil(t_cub *cl, int32_t y, int32_t x)
@@ -98,6 +59,6 @@ int8_t
ft_draw_texture(cl, x, y, tex_y);
y++;
}
- ft_draw_floor(cl, y, x);
+ /* ft_draw_floor(cl, y, x); */
return (0);
}
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index 3343fc3..ddc7bde 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -13,33 +13,7 @@
#include <cub3d.h>
#include <stdint.h>
-#include <stdio.h>
-void
- ft_floor_cast(t_cub *cl)
-{
- t_ray *rl;
- const uint32_t map_x = (uint32_t)cl->plist.pos_x;
- const uint32_t map_y = (uint32_t)cl->plist.pos_y;
-
- rl = &cl->rlist;
- if (rl->side == 0 && rl->x_ray_dir > 0)
- {
- rl->floor_x_wall = map_x;
- rl->floor_y_wall = map_y + rl->wall_hit_x;
- }
- else if (rl->side == 0 && rl->x_ray_dir < 0)
- {
- rl->floor_x_wall = map_x + 1.0;
- rl->floor_y_wall = map_y + rl->wall_hit_x;
- }
- else if (rl->side == 1 && rl->y_ray_dir > 0)
- {
- rl->floor_x_wall = map_x + rl->wall_hit_x;
- rl->floor_y_wall = map_y;
- }
- else
- {
- rl->floor_x_wall = map_x + rl->wall_hit_x;
- rl->floor_y_wall = map_y + 1.0;
- }
-}
+/* void */
+/* ft_floor_cast(t_cub *cl) */
+/* { */
+/* } */
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 0a4b8b5..78c8bb4 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -117,7 +117,7 @@ void
while (i < wl->x_size)
{
ft_initray(i, cl);
- ft_floor_cast(cl);
+ /* ft_floor_cast(cl); */
cl->rlist.line_h = (int16_t)(wl->y_size / cl->rlist.wall_dist);
cl->rlist.wall_t = -cl->rlist.line_h / 2 + wl->y_size / 2;
if (cl->rlist.wall_t < 0)