This project has been created as part of the 42 curriculum by maiguna and marfranc.
cub3D is a 3D maze exploration project inspired by the game Wolfenstein 3D, one of the first First-Person Shooter games ever made. Our project is build entirely in C using the MiniLibX graphics library, it implements a raycasting engine from scratch to simulate a 3D perspective inside a 2D map.
The goal is to render a navigable 3D environment parsed from a .cub scene file, handling textures for each wall direction (North, South, East, West) and a configurable floor/ceiling color. The player can move and rotate through the maze in real time.
- Raycasting engine rendering walls with different textures per direction (N/S/E/W)
- Smooth player movement and camera rotation
- Scene configuration via
.cubfile (map, textures, colors) - Map validation (closed walls, valid characters, etc.)
- Floor and ceiling color rendering
- Wall collisions — the player cannot walk through walls
- Minimap system — a top-down minimap overlay showing the player's position
- Linux
gcccompilermake- MiniLibX (included or installable via the system)
clone the report of our cub3D (from Github ou git's link Intra V2/V3)
cd cub3D
git clone https:\/\/github.com/42paris/minilibx-linux.git
make or make valgrind to use is with valgrind./cub3D maps/map.cub| Key | Action |
|---|---|
W / ↑ |
Move forward |
S / ↓ |
Move backward |
A |
Strafe left |
D |
Strafe right |
← |
Rotate camera left |
→ |
Rotate camera right |
ESC / x |
Quit the game |
NO ./textures/north.xpm
SO ./textures/south.xpm
WE ./textures/west.xpm
EA ./textures/east.xpm
F 220,100,0
C 30,30,200
1111111
1000001
1011101
111111111010001
100000000010001
111111111110001
100 1
111111
NO/SO/WE/EA— paths to XPM wall texturesF/C— Floor / Ceiling RGB colors- Map must be surrounded by walls (
1), spaces allowed outside
- Raycasting and Digital Differential Analyzer (DDA)
- https://fr.wikipedia.org/wiki/Raycasting
- http://zupi.free.fr/PTuto/index.php?ch=ptuto&p=ray
- https://www.youtube.com/watch?v=gYRrGTC7GtA
- https://scratch.mit.edu/projects/editor/?tutorial=getStarted
- https://medium.com/@mr.mhdhilali/cub3d-building-a-3d-world-from-a-2d-map-how-raycasting-really-works-9589466edf39
- https://permadi.com/1996/05/ray-casting-tutorial-1/
- https://www.youtube.com/watch?v=NbSee-XM7WA
- https://www.youtube.com/watch?v=W5P8GlaEOSI
- https://perso.esiee.fr/~buzerl/sphinx_IMA/80%20raycast/raycast.html
- https://en.wikipedia.org/wiki/Digital_differential_analyzer_(graphics_algorithm)
- MiniLibX Documentation (42) (https://harm-smits.github.io/42docs/libs/minilibx)
- MiniLibX Linux (https://github.com/42Paris/minilibx-linux)
AI (Claude by Anthropic) was used during this project for the following tasks:
- Debugging — helping identify logic errors in the raycasting loop and texture mapping
- Math explanations — clarifying DDA algorithm steps and vector math for player direction and camera plane
- README writing — generating and structuring this documentation