

This project is the 42 project cub3d. The goal of this project is to build a raycasting engine inspired by
Wolfenstein 3D, rendering a first-person view of a maze from a 2D map. The program reads a .cub configuration file
defining textures, colors, and the map layout, then uses DDA raycasting to project textured 3D walls in real-time.
- Raycasting with DDA (Digital Differential Analyzer) algorithm for grid intersection detection
- Textured walls (4 directional textures: NO, SO, WE, EA)
- Graphics via MLX42
- Configurable floor & ceiling colors (RGB)
- Smooth movement (WASD) and rotation (arrow keys)
- Collision system with configurable hitbox
- Distance-based shading for depth effectPlan
- Real-time minimap
- Robust
.cubfile parsing with descriptive error messages
Raycasting is a pipeline of trigonometry problems solved for each of the 1024 vertical screen columns for each frame:
- DDA: find the closest ray intersection with a wall
- Fish-eye correction: compute the actual distance to remove the spherical distortion
- Wall-height scaling: compute the wall height based on the distance of the wall
- Texture selection: select the correct texture (N/S/E/W) based on the intersection and the viewing angle
- Texture slicing: scale the texture to fill the wall
- Shading: darken rgba of computed pixel based on the distance
-
Cloning:
git clone https://github.com/michmos/raycaster.git && cd raycaster && make
-
Running: Run the executable with a
.cubmap file as argument:./cub3d maps/all_walls.cubChoose any map from the
maps/directory or create your own. -
Controls:
Key Action W/A/S/DMove forward / strafe left / backward / strafe right ← →Rotate view left / right ESCQuit the game