Fix north/south textures

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-09-02 17:47:16 +02:00
parent 195817f2d9
commit 95ca1767f9
+14 -6
View File
@@ -593,6 +593,8 @@ void drawRays3D()
// * Cast n rays // * Cast n rays
for (r = 0; r < 60; r++) for (r = 0; r < 60; r++)
{ {
int verticalMapTexture = 0;
int horizontalMapTexture = 0;
// * --- Check Horizontal Lines --- // * --- Check Horizontal Lines ---
dof = 0; dof = 0;
@@ -676,6 +678,8 @@ void drawRays3D()
hy = rayY; hy = rayY;
distanceHor = distance(playerX, playerY, hx, hy, rayAngle); distanceHor = distance(playerX, playerY, hx, hy, rayAngle);
verticalMapTexture = map[mapPoint] - 1;
dof = 8; // Break the loop - no need to calculate more. dof = 8; // Break the loop - no need to calculate more.
} }
else else
@@ -744,6 +748,8 @@ void drawRays3D()
vy = rayY; vy = rayY;
distanceVert = distance(playerX, playerY, vx, vy, rayAngle); distanceVert = distance(playerX, playerY, vx, vy, rayAngle);
verticalMapTexture = map[mapPoint] - 1;
dof = 8; // Break the loop - no need to calculate more. dof = 8; // Break the loop - no need to calculate more.
} }
else else
@@ -762,6 +768,7 @@ void drawRays3D()
// Vertical wall hit // Vertical wall hit
if (distanceVert < distanceHor) if (distanceVert < distanceHor)
{ {
horizontalMapTexture = verticalMapTexture;
rayX = vx; rayX = vx;
rayY = vy; rayY = vy;
disT = distanceVert; disT = distanceVert;
@@ -777,6 +784,7 @@ void drawRays3D()
// Horizontal wall hit // Horizontal wall hit
if (distanceHor < distanceVert) if (distanceHor < distanceVert)
{ {
horizontalMapTexture = mh - 1;
rayX = hx; rayX = hx;
rayY = hy; rayY = hy;
disT = distanceHor; disT = distanceHor;
@@ -853,25 +861,25 @@ void drawRays3D()
if (shade == 1) // North-south walls (PI -> (2 * PI)) if (shade == 1) // North-south walls (PI -> (2 * PI))
{ {
textureX = (int)(rayX / 2.0) % mapSize; textureX = (int)(rayX / 2.0) % 32;
if (rayAngle < PI) // South walls if (rayAngle < PI) // South walls
{ {
textureX = mapSize - 1 - textureX; textureX = 31 - textureX;
} }
} }
else // East-west walls (PI2 -> PI3) else // East-west walls (PI2 -> PI3)
{ {
textureX = (int)(rayY / 2.0) % mapSize; textureX = (int)(rayY / 2.0) % 32;
if (rayAngle > PI2 && rayAngle < PI3) // West if (rayAngle > PI2 || rayAngle < PI3) // West
{ {
textureX = mapSize - 1 - textureX; textureX = 31 - textureX;
} }
} }
for (x = xStart; x < xEnd; x++) for (x = xStart; x < xEnd; x++)
{ {
float textureY = textureYoffset * textureYstep; float textureY = textureYoffset * textureYstep + (horizontalMapTexture * 32);
for (y = 0; y < lineHeight; y++) for (y = 0; y < lineHeight; y++)
{ {
float c = All_Textures[((int)textureY * mapSize) + textureX] * shade; float c = All_Textures[((int)textureY * mapSize) + textureX] * shade;