diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-03-07 20:32:17 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-03-07 20:32:17 +0100 |
commit | 9336d5812fc107127215bbfcf1bf86e128c9586c (patch) | |
tree | c77d632f32c6e12d913a7984cdd9d249c5ed50ff | |
parent | qwe (diff) | |
download | 42-cub3d-9336d5812fc107127215bbfcf1bf86e128c9586c.tar.gz 42-cub3d-9336d5812fc107127215bbfcf1bf86e128c9586c.tar.bz2 42-cub3d-9336d5812fc107127215bbfcf1bf86e128c9586c.tar.xz 42-cub3d-9336d5812fc107127215bbfcf1bf86e128c9586c.tar.zst 42-cub3d-9336d5812fc107127215bbfcf1bf86e128c9586c.zip |
DIVINE INTELLECT
-rw-r--r-- | inc/cub3d.h | 4 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 1 | ||||
-rw-r--r-- | src/ft_darken_rgb.c | 8 | ||||
-rw-r--r-- | src/ft_draw_verline.c | 6 |
4 files changed, 8 insertions, 11 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h index 5c37433..063b06f 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -130,8 +130,8 @@ uint8_t ft_free_words(char **words); int8_t ft_warp_level(t_cub *cl); int ft_exit(uint8_t exit_code, t_cub *clist); uint32_t ft_rgb_to_hex(t_rgb rgb); -uint32_t ft_darken_ceil(t_rgb rgb, t_cub *cl); -uint32_t ft_darken_floor(t_rgb rgb, t_cub *cl); +uint32_t ft_darken_ceil(t_rgb rgb, int32_t y, t_cub *cl); +uint32_t ft_darken_floor(t_rgb rgb, int32_t y, t_cub *cl); t_bmp_rgb ft_hex_to_rgb(uint32_t color); # endif diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 4638030..d392f0c 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -192,7 +192,6 @@ typedef struct s_cub struct s_rgb c_rgb; struct s_img tlist[6]; struct s_sprite sp_list; - int32_t y; } t_cub; # endif diff --git a/src/ft_darken_rgb.c b/src/ft_darken_rgb.c index fe69fa2..564dfbd 100644 --- a/src/ft_darken_rgb.c +++ b/src/ft_darken_rgb.c @@ -15,13 +15,13 @@ #include <stdio.h> uint32_t - ft_darken_ceil(t_rgb rgb, t_cub *cl) + ft_darken_ceil(t_rgb rgb, int32_t y, t_cub *cl) { t_rgb darker; float calc; darker = rgb; - calc = ((float)(cl->y - (75000.0 / cl->wlist.y_size)) + calc = ((float)(y - (75000.0 / cl->wlist.y_size)) / (cl->wlist.y_size / 2)); calc = (calc < 0) ? (0) : (calc); darker.r *= 1 - calc; @@ -31,12 +31,12 @@ uint32_t } uint32_t - ft_darken_floor(t_rgb rgb, t_cub *cl) + ft_darken_floor(t_rgb rgb, int32_t y, t_cub *cl) { t_rgb darker; float calc; - calc = ((float)(cl->y + (75000.0 / cl->wlist.y_size)) + calc = ((float)(y + (75000.0 / cl->wlist.y_size)) / (cl->wlist.y_size / 2)) - 1.0; calc = (calc < 0) ? (0) : (calc); darker = rgb; diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c index 8621668..18f7cfe 100644 --- a/src/ft_draw_verline.c +++ b/src/ft_draw_verline.c @@ -18,10 +18,9 @@ static void { while ((uint32_t)y < cl->wlist.y_size) { - cl->y = y; *(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) - = ft_darken_floor(cl->f_rgb, cl); + = ft_darken_floor(cl->f_rgb, y, cl); y++; } } @@ -34,10 +33,9 @@ static void i = 0; while (i <= y) { - cl->y = i; *(int*)(cl->img.ptr + (x * 4 + (i * cl->img.sizeline))) - = ft_darken_ceil(cl->c_rgb, cl); + = ft_darken_ceil(cl->c_rgb, i, cl); i++; } } |