Allow changing color of wall based on map value
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
+19
-3
@@ -45,7 +45,7 @@ int map[] =
|
||||
1,0,1,0,0,0,0,1,
|
||||
1,0,1,0,0,0,0,1,
|
||||
1,0,0,0,0,0,0,1,
|
||||
1,0,0,0,0,1,0,1,
|
||||
1,0,0,0,0,2,0,1,
|
||||
1,0,0,0,0,0,0,1,
|
||||
1,1,1,1,1,1,1,1,
|
||||
};
|
||||
@@ -178,6 +178,8 @@ void drawRays3D()
|
||||
ry = py;
|
||||
}
|
||||
|
||||
int mv = 0, mh = 0;
|
||||
|
||||
// ? We don't want to get caught in an infinite loop, so use the
|
||||
// depth-of-field to limit our check to a max of 8.
|
||||
while (dof < 8)
|
||||
@@ -193,10 +195,12 @@ void drawRays3D()
|
||||
// If the map position is less than the array's size, then we can check it
|
||||
// inside the map. If the value is 1, there's a wall. If we hit a wall,
|
||||
// we're done!
|
||||
if (mp > 0 && mp < mapX * mapY && map[mp] == 1)
|
||||
if (mp > 0 && mp < mapX * mapY && map[mp] > 0)
|
||||
{
|
||||
// We hit a wall!
|
||||
|
||||
mh = map[mp];
|
||||
|
||||
// Save the values and calculate the distance from the player
|
||||
hx = rx;
|
||||
hy = ry;
|
||||
@@ -259,10 +263,12 @@ void drawRays3D()
|
||||
// If the map position is less than the array's size, then we can check it
|
||||
// inside the map. If the value is 1, there's a wall. If we hit a wall,
|
||||
// we're done!
|
||||
if (mp > 0 && mp < mapX * mapY && map[mp] == 1)
|
||||
if (mp > 0 && mp < mapX * mapY && map[mp] > 0)
|
||||
{
|
||||
// We hit a wall!
|
||||
|
||||
mv = map[mp];
|
||||
|
||||
// Save the values and calculate the distance from the player
|
||||
vx = rx;
|
||||
vy = ry;
|
||||
@@ -291,6 +297,11 @@ void drawRays3D()
|
||||
disT = disV;
|
||||
// Vertical walls are drawn a little brighter than horizontal walls
|
||||
glColor3f(0.9, 0, 0);
|
||||
|
||||
if (mv == 2)
|
||||
{
|
||||
glColor3f(0, 0, 0.7);
|
||||
}
|
||||
}
|
||||
|
||||
// Horizontal wall hit
|
||||
@@ -301,6 +312,11 @@ void drawRays3D()
|
||||
disT = disH;
|
||||
// Horizontal walls are drawn a little darker than vertical walls
|
||||
glColor3f(0.7, 0, 0);
|
||||
|
||||
if (mh == 2)
|
||||
{
|
||||
glColor3f(0, 0, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
// * Draw the ray
|
||||
|
||||
Reference in New Issue
Block a user