aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_map.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p1.le-101.fr>2020-02-14 21:00:02 +0100
committerRudy Bousset <rbousset@z2r4p1.le-101.fr>2020-02-14 21:00:02 +0100
commita95f7c219961b16be72febd645191e5a0d4aad4d (patch)
treea3a49e80b550742e4f9c5fe890bb6ef76ad2486e /src/ft_draw_map.c
parentNew define .h (diff)
download42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.tar.gz
42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.tar.bz2
42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.tar.xz
42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.tar.zst
42-cub3d-a95f7c219961b16be72febd645191e5a0d4aad4d.zip
Good player spawn view for N and S, minimap bot left StarCraft style
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;