From c4b664714b60c07fb5d84b8fe1fc7a77875a1679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 1 Sep 2018 09:55:35 +0200 Subject: [PATCH] Make render work --- raycastlib.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index 2533d17..d693393 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -537,10 +537,13 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) PixelInfo p; p.position.x = x; + // draw floor until the wall + p.isWall = 0; - // draw floor until the wall - for (int32_t i = y; i > z1Screen; --i) + Unit zTop = z1Screen < z2Screen ? z1Screen : z2Screen; + + for (int32_t i = y; i > zTop; --i) { p.position.y = i; _pixelFunction(p); @@ -557,7 +560,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) _pixelFunction(p); } - y = z2Screen; + y = y > zTop ? zTop : y; worldZPrev = worldZ2; } }