Cub3D is the second team project in the 42 core curriculum (partner->Clemens). It is a simplified 3D graphics engine based on raycasting, inspired by Wolfenstein 3D. This project aims to deepen our understanding of 3D rendering, vector math, and event-driven programming using the MLX graphics library.

Cub3D is a raycasting-based first-person 3D engine. It renders a 2D map in a pseudo-3D view using minimal graphical primitives. The player can navigate through a maze with textures applied to walls and floors, mimicking depth and perspective.
This project teaches:
- Basics of raycasting (DDA algorithm)
- Vector math and trigonometry
- Real-time rendering and game loops
- Handling player input and collisions
- Texture mapping
- โ Raycasting engine (DDA algorithm)
- โ Player movement & rotation
- โ Wall collision detection
- โ Texture rendering for walls
- โ Minimap
- โ Door mechanics
- โ Mouse support
- โ Sprite rendering (gif walls and doors)
- โ Customizable settings
- Activate/deactivate minimap (press m). Some settings are visible in the minimap so make sure to have it activated when you check them out for the first time.
- Open/close door (press spacebar). Doors are visible in the minimap as black tiles if opened and as white if closed. In the config they are set as 2 if closed and as 3 if opened.
- Door on the right is closed.
- Door on the right is open.
- Activate/deactivate mouse (press v). Check out the incredible message that's printed in your terminal after pressing "v". While activated you can turn left/right with your mouse.
Use gif files in the config file to check out moving walls and doors. If the gif is very big the program will be a bit slow (rickgif is the slowest).
- Press G to activate a settings selection in the terminal of the running program. To select one press left Shift and scroll with your mouse. The selected setting will be light green and can be customized using the mouse wheel.
make./cub3D maps/select_a_map.cubYou can find the valid maps inside the maps directory. You can also attempt making your own map.
- Key Action
- W / โ Move forward
- S / โ Move backward
- A Strafe left
- D Strafe right
- โ / โ Turn left/right
- ESC Exit game
- Mouse look if enabled with v during play.
- The map must be surrounded by walls (
1). - Player start position must be one of the following:
N,S,E, orW.
- The following identifiers are mandatory:
NO,SO,WE,EAโ Wall textures- Floor and Ceiling RGB colors
DOfor door is optional.- Use
2for a closed door,3for an open door.
| Symbol | Meaning |
|---|---|
| 'space' | Nothing/Space |
1 |
Wall |
0 |
Empty space |
2 |
Closed door |
3 |
Open door |
N/S/E/W |
Player starting position |
NO images/DEBUG/North.png
SO images/DEBUG/South.png
WE images/DEBUG/Westh.png
EA images/DEBUG/Easth.png
DO images/DEBUG/Doorh.png
F 220,100,0
C 225,30,0
111111
100001
1000N1
100001
111111- DO for door is optional. NO, SO, WE, EA are mandatory.
- Map must be surrounded by walls (1).
- Player start position: N, S, E, or W.
- Floor/Ceiling RGB colors and wall textures are mandatory.
- 2 for a closed door, 3 for an open door.