aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_drawmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_drawmap.c')
-rw-r--r--src/ft_drawmap.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ft_drawmap.c b/src/ft_drawmap.c
index 7d7cafe..97ed6b0 100644
--- a/src/ft_drawmap.c
+++ b/src/ft_drawmap.c
@@ -46,6 +46,36 @@ static void
}
}
+void ft_drawline(t_cub *clist, int startX, int startY)
+{
+ int a;
+ int b;
+ int p;
+ int x;
+ int y;
+
+ x = startX;
+ y = startY;
+ while (x > 25 * clist->scale)
+ {
+ a = 2 * (y - 1 * clist->scale);
+ b = a - (2 * (x - 25 * clist->scale));
+ p = a - (x - 25 * clist->scale);
+ if (p < 0)
+ {
+ x--;
+ *(int*)(clist->img.ptr + (x * 4 + (y * clist->img.sizeline))) = 0x00ff0000;
+ p += a;
+ }
+ else if (p >= 0)
+ {
+ y--;
+ *(int*)(clist->img.ptr + (x * 4 + (y * clist->img.sizeline))) = 0x00ff0000;
+ p += b;
+ }
+ x--;
+ }
+}
static void
ft_draw_player(t_player *plist, t_cub *clist)
{
@@ -56,6 +86,7 @@ static void
ft_drawsquare(scale + (x * (scale + 1)),
scale + (y * (scale + 1)),
0x009843fa, clist);
+ ft_drawline(clist, x * (scale + 1), y * (scale + 1));
}
void