aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_draw_map.c')
-rw-r--r--src/ft_draw_map.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/ft_draw_map.c b/src/ft_draw_map.c
index 202439b..2e17d69 100644
--- a/src/ft_draw_map.c
+++ b/src/ft_draw_map.c
@@ -13,6 +13,14 @@
#include <cub3d.h>
#include <stdint.h>
+static uint16_t
+ ft_y_offset(t_cub *clist)
+{
+ return (clist->wlist->y_size
+ - (clist->mlist->map_h * clist->mlist->scale)
+ + clist->mlist->scale - 1);
+}
+
static void
ft_draw_player(t_player *plist, t_cub *clist)
{
@@ -22,7 +30,7 @@ static void
ft_draw_square(
scale + (x * (scale)),
- scale + (y * (scale)),
+ ft_y_offset(clist) + (y * (scale)),
0x009843fa,
clist);
}
@@ -42,13 +50,13 @@ void
{
if (map[y][x] == '1')
ft_draw_square(scale + (x * (scale)),
- scale + (y * (scale)), 0x0000ffaa, clist);
+ ft_y_offset(clist) + (y * (scale)), 0x0000ffaa, clist);
else if (map[y][x] == '2')
ft_draw_square(scale + (x * (scale)),
- scale + (y * (scale)), 0x0033ccff, clist);
+ ft_y_offset(clist) + (y * (scale)), 0x0033ccff, clist);
else
- ft_draw_square(scale + (x * (scale)), scale + (y * (scale)),
- ft_rgb_to_hex(clist->f_rgb), clist);
+ ft_draw_square(scale + (x * (scale)), ft_y_offset(clist) +
+ (y * (scale)), ft_rgb_to_hex(clist->f_rgb), clist);
x++;
}
x = 0;