diff options
-rw-r--r-- | inc/cub3d_structs.h | 2 | ||||
-rw-r--r-- | map/map_one.cub | 4 | ||||
-rw-r--r-- | src/ft_draw_sprite.c | 4 | ||||
-rw-r--r-- | src/ft_draw_verline.c | 19 | ||||
-rw-r--r-- | src/ft_raycasting.c | 4 |
5 files changed, 25 insertions, 8 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 4847d1f..102b985 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -50,6 +50,7 @@ typedef struct s_rgb typedef struct s_sprite { int32_t spritescreenx; + int8_t isvisible; int32_t x; int32_t y; int32_t tex_x; @@ -88,7 +89,6 @@ typedef struct s_ray { uint16_t line_h; float wall_dist; - float mid_dist; float x_ray_pos; float y_ray_pos; float x_ray_dir; diff --git a/map/map_one.cub b/map/map_one.cub index 644a63d..ab1ae76 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -10,9 +10,9 @@ C 50,100,200 F 50,190,124 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 +1 2 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 N 1 1 0 0 0 2 0 1 1 1 0 0 0 0 0 1 +1 N 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 0430e2f..82984d2 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -38,9 +38,7 @@ void sprite->tex_y = ((d * cl->tlist[4].img_h / 2) / sprite->spriteheight) / 128; if (cl->tlist[4].ptr[sprite->tex_x * 4 + 4 * cl->tlist[4].img_h * sprite->tex_y]) - { - cl->img.ptr[sprite->x * 4 + (sprite->y * - cl->img.sizeline)] = + {cl->img.ptr[sprite->x * 4 + (sprite->y * cl->img.sizeline)] = cl->tlist[4].ptr[sprite->tex_x * 4 + 4 * cl->tlist[4].img_h * sprite->tex_y]; cl->img.ptr[sprite->x * 4 + (sprite->y * cl->img.sizeline) + 1] = diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c index b0f9880..2b684eb 100644 --- a/src/ft_draw_verline.c +++ b/src/ft_draw_verline.c @@ -10,7 +10,24 @@ /* */ /* ************************************************************************** */ +#include <stdio.h> #include <cub3d.h> +uint32_t + ft_gradient(t_rgb rgb, int it) +{ + uint32_t res; + + (void)it; + res = 0; + if (it < 255) + { + rgb.r += it; + rgb.g += it; + rgb.b += it; + } + res += ((rgb.r << 16) + (rgb.g << 8) + rgb.b); + return (res); +} static void ft_draw_floor(t_cub *cl, int32_t y, int32_t x) @@ -18,7 +35,7 @@ static void while ((uint32_t)y < cl->wlist->y_size) { *(int*)(cl->img.ptr + - (x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(cl->f_rgb); + (x * 4 + (y * cl->img.sizeline))) = ft_gradient(cl->f_rgb, y); y++; } } diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 0cd4cc6..925711f 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -54,7 +54,9 @@ void tmp_b = cl->plist->dir_y; sprite.spritex = sprite.spritex - (cl->plist->pos_x - 0.5); sprite.spritey = sprite.spritey - (cl->plist->pos_y - 0.5); - printf("[%f] [%f] x [%f] y [%f] [%d]\n", sprite.spritex, sprite.spritey, cl->plist->dir_x, cl->plist->dir_y, i); + /* sprite.transformx */ + /* sprite.transformy */ + printf("[%f] [%f] x [%f] y [%f] [%d]\n", sprite.spritex, sprite.spritey, sprite.transformx, sprite.transformy, i); sprite.invdet = 1.0 / (cl->plist->plane_x * cl->plist->dir_y - cl->plist->dir_x * cl->plist->plane_y); sprite.transformx = sprite.invdet * (cl->plist->dir_y * |