RAYCASTING: How it's working?
Raycasting is the core technique used in this engine to transform a 2D map into a real-time 3D view.
The world is stored as a grid-based 2D array, where each cell represents either empty space or a wall.
For every vertical column of the screen, the engine casts a ray from the player's position at a specific angle.
This ray moves forward through the map until it collides with a wall cell.
distance to this wall is then calculated and used to determine the height of the vertical slice drawn on the screen.
By repeating this process for all screen columns, the engine constructs a full 3D scene from a simple 2D layout, creating the illusion of depth and perspective.
CHALENGES: Fish eye !?
The most difficult bug I faced during development was fixing the fish-eye distortion effect.
At first, walls near the edges of the screen appeared stretched and curved, which broke the realism of the scene.
This happened because the raw ray distance was being used directly, without correcting for the angle between the ray direction and the player’s view direction.
The solution was to multiply the ray distance by the cosine of this angle, which projects the distance onto the camera plane and removes the distortion.
Another major challenge was managing memory safely in C, especially when working with dynamic textures and arrays.
Debugging segmentation faults and memory leaks taught me the importance of careful allocation, validation, and cleanup in low-level programming.