diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-02-22 20:55:23 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-02-22 20:55:23 +0100 |
commit | 8a4e61b81568aeff290df59e371c99724728ce4a (patch) | |
tree | eb3528688a76c09df091bfda01f4c68a7680b36c | |
parent | Drawing some HUD (diff) | |
download | 42-cub3d-8a4e61b81568aeff290df59e371c99724728ce4a.tar.gz 42-cub3d-8a4e61b81568aeff290df59e371c99724728ce4a.tar.bz2 42-cub3d-8a4e61b81568aeff290df59e371c99724728ce4a.tar.xz 42-cub3d-8a4e61b81568aeff290df59e371c99724728ce4a.tar.zst 42-cub3d-8a4e61b81568aeff290df59e371c99724728ce4a.zip |
Perfect
Diffstat (limited to '')
-rw-r--r-- | src/ft_draw_hud.c | 56 | ||||
-rw-r--r-- | src/ft_draw_map.c | 12 | ||||
-rw-r--r-- | src/ft_draw_square.c | 4 | ||||
-rw-r--r-- | src/ft_get_res.c | 4 |
4 files changed, 65 insertions, 11 deletions
diff --git a/src/ft_draw_hud.c b/src/ft_draw_hud.c index 1564e2e..68cdac5 100644 --- a/src/ft_draw_hud.c +++ b/src/ft_draw_hud.c @@ -12,15 +12,69 @@ #include <cub3d.h> #include <mlx.h> +#include <stdint.h> static void -ft_draw_hud_back(t_win *wl, t_cub *cl) + ft_draw_hud_back(t_win *wl, t_cub *cl) { + const uint16_t scl = cl->mlist->scale; + uint32_t x; + uint32_t y; + + x = 0; + y = wl->y_size - ((cl->mlist->map_h * scl)); + while (x < wl->x_size) + { + while (y < wl->y_size) + { + *(int*)(cl->img.ptr + (x * 4 + + (y * cl->img.sizeline))) = 0x00808080; + y++; + } + y = wl->y_size - ((cl->mlist->map_h * scl)); + x++; + } +} + +static void + ft_draw_hud_back_top(size_t map_h, size_t map_w, t_win *wl, t_cub *cl) +{ + const uint16_t scl = cl->mlist->scale; + uint32_t x; + uint32_t y; + + x = 0; + y = wl->y_size - (map_h * scl) - 20; + while (x < (map_w * scl) + 20) + { + while (y < wl->y_size - (map_h * scl)) + { + *(int*)(cl->img.ptr + (x * 4 + + (y * cl->img.sizeline))) = 0x00808080; + y++; + } + y = wl->y_size - (map_h * scl) - 20; + x++; + } + x = wl->x_size - (map_w * scl) + 20; + while (x < wl->x_size) + { + while (y < wl->y_size - (map_h * scl)) + { + *(int*)(cl->img.ptr + (x * 4 + + (y * cl->img.sizeline))) = 0x00808080; + y++; + } + y = wl->y_size - (map_h * scl) - 20; + x++; + } } void ft_draw_hud(t_cub *clist) { ft_draw_hud_back(clist->wlist, clist); + ft_draw_hud_back_top(clist->mlist->map_h, + clist->mlist->map_w, clist->wlist, clist); ft_draw_map(clist->mlist->map, clist); } diff --git a/src/ft_draw_map.c b/src/ft_draw_map.c index 39299c1..db915e4 100644 --- a/src/ft_draw_map.c +++ b/src/ft_draw_map.c @@ -49,14 +49,14 @@ void while (map[y][x]) { if (map[y][x] == '1') - ft_draw_square(scale + (x * (scale)), - ft_y_offset(clist) + (y * (scale)), 0x0000ffaa, clist); + ft_draw_square(scale + 9 + (x * (scale)), + ft_y_offset(clist) - 9 + (y * (scale)), 0x0000ffaa, clist); else if (map[y][x] == '2') - ft_draw_square(scale + (x * (scale)), - ft_y_offset(clist) + (y * (scale)), 0x0033ccff, clist); + ft_draw_square(scale + 9 + (x * (scale)), + ft_y_offset(clist) - 9 + (y * (scale)), 0x0033ccff, clist); else - ft_draw_square(scale + (x * (scale)), ft_y_offset(clist) + - (y * (scale)), ft_rgb_to_hex(clist->f_rgb), clist); + ft_draw_square(scale + 9 + (x * (scale)), ft_y_offset(clist) + - 9 + (y * (scale)), ft_rgb_to_hex(clist->f_rgb), clist); x++; } x = 0; diff --git a/src/ft_draw_square.c b/src/ft_draw_square.c index 8bbce36..355969e 100644 --- a/src/ft_draw_square.c +++ b/src/ft_draw_square.c @@ -23,9 +23,9 @@ void x = a; y = b; - while (x > a - scale) + while (x >= a - scale) { - while (y > b - scale) + while (y >= b - scale) { *(int*)(clist->img.ptr + (x * 4 + (y * clist->img.sizeline))) = rgb; y--; diff --git a/src/ft_get_res.c b/src/ft_get_res.c index 8607f62..dece00f 100644 --- a/src/ft_get_res.c +++ b/src/ft_get_res.c @@ -48,8 +48,8 @@ int8_t return (-1); wlist->x_size = ft_atoi(words[1]); wlist->y_size = ft_atoi(words[2]); - if (wlist->x_size <= 1 - || wlist->y_size <= 1) + if (wlist->x_size <= 10 + || wlist->y_size <= 10) { ft_strlcpy(clist->errmsg, FT_ERR_RES_SMALL, ft_strlen(FT_ERR_RES_SMALL) + 1); |