title: Why are my walls invisible from the back?
body: <p>I'm currently working on a Java project which deals with creating a 3D maze game, but I have an issue with the walls. Indeed,when we walk around a wall, it disappears; it's like the wall can't be seen from the back.</p>
  
  <p>Here is my code (mainly from YouTube user "<a href="https://www.youtube.com/user/TheChernoProject" rel="nofollow">thecherno</a>"):</p>
  
  <pre><code>public void renderWall(double xLeft, double xRight, double zDistanceLeft, double zDistanceRight, double yHeight) {
      double upCorrect = 0.0625;
      double rightCorrect = 0.0625;
      double forwardCorrect = 0.0625;
      double walkCorrect = -0.0625;
  
      /* que se passe t-il quand on bouge vers la gauche sur l'axe des x */
      double xcLeft = ((xLeft) - (right * rightCorrect)) * 2;
      /* sur la gauche sur l'axe des z */
      double zcLeft = ((zDistanceLeft) - (forward * forwardCorrect)) * 2;
  
      /* quand on fait une rotation vers la gauche sur l'axe des x */
      double rotLeftSideX = xcLeft * cosine - zcLeft * sine;
      /* le coin du mur haut gauche */
      double yCornerTL = ((-yHeight) - (-up * upCorrect + (walking * walkCorrect))) * 2;
      /* bas gauche */
      double yCornerBL = ((+0.5 - yHeight) - (-up * upCorrect + (walking * walkCorrect))) * 2;
      /* quand on fait une rotation vers la gauche sur l'axe des z */
      double rotLeftSideZ = zcLeft * cosine + xcLeft * sine;
  
      /* Pour la droite */
      double xcRight = ((xRight) - (right * rightCorrect)) * 2;
      double zcRight = ((zDistanceRight) - (forward * forwardCorrect)) * 2;
  
      double rotRightSideX = xcRight * cosine - zcRight * sine;
      double yCornerTR = ((-yHeight) - (-up * upCorrect + (walking * walkCorrect))) * 2;
      double yCornerBR = ((+0.5 - yHeight) - (-up * upCorrect + (walking * walkCorrect))) * 2;
      double rotRightSideZ = zcRight * cosine + xcRight * sine;
  
      double tex30 = 0;
      double tex40 = 8;
      double clip = 0.5;
      if (rotLeftSideZ &lt; clip &amp;&amp; rotRightSideZ &lt; clip) {
          return;
      }
      if (rotLeftSideZ &lt; clip) {
          double clip0 = (clip - rotLeftSideZ) / (rotRightSideZ - rotLeftSideZ);
          rotLeftSideZ = rotLeftSideZ + (rotRightSideZ - rotLeftSideZ) * clip0;
          rotLeftSideX = rotLeftSideX + (rotRightSideX - rotLeftSideX) * clip0;
          tex30 = tex30 + (tex40 - tex30) * clip0;
      }
      if (rotRightSideZ &lt; clip) {
          double clip0 = (clip - rotLeftSideZ) / (rotRightSideZ - rotLeftSideZ);
          rotRightSideZ = rotLeftSideZ + (rotRightSideZ - rotLeftSideZ) * clip0;
          rotRightSideX = rotLeftSideX + (rotRightSideX - rotLeftSideX) * clip0;
          tex40 = tex30 + (tex40 - tex30) * clip0;
      }
  
  
      double xPixelLeft = (rotLeftSideX / rotLeftSideZ * height + width / 2);
      double xPixelRight = (rotRightSideX / rotRightSideZ * height + width / 2);
  
      /* si le coté gauche du mur passe au dela du coté droit */
      if (xPixelLeft &gt;= xPixelRight) {
          return;
      }
  
      /*
       * On cast les double en entier car les pixels sont placé dans un
       * tableau d'entier
       */
      int xPixelLeftInt = (int) (xPixelLeft);
      int xPixelRightInt = (int) (xPixelRight);
  
      /* Si ca depasse, on rend rien */
      if (xPixelLeftInt &lt; 0) {
          xPixelLeftInt = 0;
      }
      if (xPixelRightInt &gt; width) {
          xPixelRightInt = width;
      }
  
      double yPixelLeftTop = (yCornerTL / rotLeftSideZ * height + height / 2.0);
      double yPixelLeftBottom = (yCornerBL / rotLeftSideZ * height + height / 2.0);
      double yPixelRightTop = (yCornerTR / rotRightSideZ * height + height / 2.0);
      double yPixelRightBottom = (yCornerBR / rotRightSideZ * height + height / 2.0);
  
      double tex1 = 1 / rotLeftSideZ;
      double tex2 = 1 / rotRightSideZ;
      double tex3 = 0 / rotLeftSideZ;
      double tex4 = 8 / rotRightSideZ - tex3;
  
      for (int x = xPixelLeftInt; x &lt; xPixelRightInt; x++) {
  
          double pixelRotation = (x - xPixelLeft) / (xPixelRight - xPixelLeft);
          double zWall = (tex1 + (tex2 - tex1) * pixelRotation);
  
          if(zBufferWall[x] &gt; zWall){
              continue;
          }
  
          zBufferWall[x] = zWall;
          int xTexture = (int) ((tex3 + tex4 * pixelRotation) / (tex1 + (tex2 - tex1) * pixelRotation));
  
          double yPixelTop = yPixelLeftTop + (yPixelRightTop - yPixelLeftTop) * pixelRotation;
          double yPixelBottom = yPixelLeftBottom + (yPixelRightBottom - yPixelLeftBottom) * pixelRotation;
  
          int yPixelTopInt = (int) (yPixelTop);
          int yPixelBottomInt = (int) (yPixelBottom);
  
          /* Si ca depasse, on rend rien */
          if (yPixelTopInt &lt; 0) {
              yPixelTopInt = 0;
          }
          if (yPixelBottomInt &gt; height) {
              yPixelBottomInt = height;
          }
  
          for (int y = yPixelTopInt; y &lt; yPixelBottomInt; y++) {
              double pixelRotationY = (y - yPixelTop) / (yPixelBottom - yPixelTop);
              int yTexture = (int) (8 * pixelRotationY);
              // pixels[x + y * width] = xTexture * 100 + yTexture * 100 *
              // 256;
              pixels[x + y * width] = Texture.floor.pixels[(xTexture &amp; 7) + 8 + (yTexture &amp; 7) * 16];
              zBuffer[x + y * width] = 1 / (tex1 + (tex2 - tex1) * pixelRotation) * 8;
          }
      }
  }
  </code></pre>
  
  <p>I think that the problem come from this:</p>
  
  <pre><code>if (xPixelLeft &gt;= xPixelRight) {
      return;
  }
  </code></pre>
  
  <p>Why does the code include lines that cause walls to disappear, and how should I make walls visible from both sides?</p>