diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_darken_rgb.c | 9 | ||||
-rw-r--r-- | src/ft_draw_hud.c | 4 | ||||
-rw-r--r-- | src/ft_draw_scene.c | 34 | ||||
-rw-r--r-- | src/ft_draw_verline.c | 2 |
4 files changed, 44 insertions, 5 deletions
diff --git a/src/ft_darken_rgb.c b/src/ft_darken_rgb.c index 97d0c0e..3587d72 100644 --- a/src/ft_darken_rgb.c +++ b/src/ft_darken_rgb.c @@ -15,12 +15,15 @@ #include <stdio.h> uint32_t - ft_darken_rgb(t_rgb rgb, int32_t y, t_cub *cl) + ft_darken_rgb(t_rgb rgb, t_cub *cl) { t_rgb darker; - uint8_t calc; + float dist; + float calc; - calc = (((cl->wlist.y_size / 2) + y)), + if ((dist = cl->rlist.wall_dist) <= 0) + dist = 0.0001; + calc = (dist * 0.2); calc = (calc >= 255) ? (255) : (calc); calc = (calc < 1) ? (1) : (calc); darker = rgb; diff --git a/src/ft_draw_hud.c b/src/ft_draw_hud.c index f807714..fe73af8 100644 --- a/src/ft_draw_hud.c +++ b/src/ft_draw_hud.c @@ -10,6 +10,7 @@ /* */ /* ************************************************************************** */ +#include <libft.h> #include <cub3d.h> #include <mlx.h> #include <stdint.h> @@ -43,10 +44,11 @@ static void } } -void +int8_t ft_draw_hud(t_cub *clist) { ft_draw_minimap_back(clist->mlist.map_h, clist->mlist.map_w, &clist->wlist, clist); ft_draw_map(clist->mlist.map, clist); + return (0); } diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c index 9461eef..f96eae6 100644 --- a/src/ft_draw_scene.c +++ b/src/ft_draw_scene.c @@ -15,6 +15,30 @@ #include <mlx.h> #include <stdint.h> +static int8_t + ft_put_stage(t_cub *clist) +{ + const uint32_t x = 15; + const uint32_t y = clist->wlist.y_size + - (clist->mlist.map_h * clist->mlist.scale) - 20; + const uint8_t len = 6 + ft_uintlen(clist->currlvl); + char *str; + + if (!(str = (char*)malloc((len + 1) * sizeof(char)))) + return (-1); + ft_sprintf(str, "Stage %hd", clist->currlvl); + if (clist->mlist.isnlvl) + { + mlx_string_put(clist->wlist.wlx, + clist->wlist.winptr, + x, y, + 0x00ff0000, + str); + } + ft_memdel((void**)&str); + return (0); +} + void ft_draw_scene(t_cub *clist) { @@ -24,9 +48,19 @@ void &clist->img.sizeline, &clist->img.endian); ft_castray(clist); if (clist->ishud) + { ft_draw_hud(clist); + ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist); + } mlx_put_image_to_window(clist->wlist.wlx, clist->wlist.winptr, clist->img.img, 0, 0); + if (clist->ishud) + { + if (ft_put_stage(clist) < 0) + { + ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist); + } + } mlx_destroy_image(clist->wlist.wlx, clist->img.img); } diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c index 5250dc7..3198357 100644 --- a/src/ft_draw_verline.c +++ b/src/ft_draw_verline.c @@ -35,7 +35,7 @@ static void { *(int*)(cl->img.ptr + (x * 4 + (i * cl->img.sizeline))) - = ft_rgb_to_hex(cl->c_rgb); + = ft_darken_rgb(cl->c_rgb, cl); i++; } } |