Add some simple shading to the walls
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
+8
-3
@@ -282,22 +282,28 @@ void drawRays3D()
|
||||
|
||||
// * Compare shortest horizontal and vertical line, then use the shortest
|
||||
// This is what actually determines our ray that hits a wall!
|
||||
|
||||
// Vertical wall hit
|
||||
if (disV < disH)
|
||||
{
|
||||
rx = vx;
|
||||
ry = vy;
|
||||
disT = disV;
|
||||
// Vertical walls are drawn a little brighter than horizontal walls
|
||||
glColor3f(0.9, 0, 0);
|
||||
}
|
||||
|
||||
// Horizontal wall hit
|
||||
if (disH < disV)
|
||||
{
|
||||
rx = hx;
|
||||
ry = hy;
|
||||
disT = disH;
|
||||
// Horizontal walls are drawn a little darker than vertical walls
|
||||
glColor3f(0.7, 0, 0);
|
||||
}
|
||||
|
||||
// * Draw the shortest line
|
||||
glColor3f(1, 0, 0);
|
||||
// * Draw the ray
|
||||
glLineWidth(3);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(px, py);
|
||||
@@ -307,7 +313,6 @@ void drawRays3D()
|
||||
// * --- Draw 3D Walls ---
|
||||
|
||||
// Correct the fish-eye effect
|
||||
|
||||
float ca = pa - ra;
|
||||
if (ra < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user