aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-05 20:56:58 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-05 20:56:58 +0100
commitd105248f0b08a5c37221a91365a8edb56ce6766d (patch)
tree55275df48ab00b9a9998239ed2a79e45fad674eb /src
parentNorme (diff)
download42-cub3d-d105248f0b08a5c37221a91365a8edb56ce6766d.tar.gz
42-cub3d-d105248f0b08a5c37221a91365a8edb56ce6766d.tar.bz2
42-cub3d-d105248f0b08a5c37221a91365a8edb56ce6766d.tar.xz
42-cub3d-d105248f0b08a5c37221a91365a8edb56ce6766d.tar.zst
42-cub3d-d105248f0b08a5c37221a91365a8edb56ce6766d.zip
Experiment
Diffstat (limited to 'src')
-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