Logic
for each vertical column of the screen a ray is cast from player's position in to the map THE DIRECTION OF THIS RAY IS CALCULATED uding the player's viewing direction combined with the camera plain. the ray then advances through the grid cell by cell using DDA until it hits a wall. Once a wall is hit, the perpendicular distance from the player to the wall is computed. This distance is used to determine the height of the vertical line drawn on the screen for that column: closer walls appear taller, while farther walls appear shorter. Drawing these vertical slices side by side creates the illusion of a 3D scene.