cub3D is a 42 School project recreating a basic 3D game engine using raycasting — the same technique behind early 90s shooters like Wolfenstein 3D.
This project introduces essential concepts in graphics rendering, event-driven programming, and 3D projection math, all while following strict C coding standards.
🎉 Final Grade: 125/100 (with bonus)
- Master window and image management with MiniLibX.
- Implement raycasting for pseudo-3D visualization.
- Apply trigonometry and vector math for projections.
- Handle textures, colors, and real-time rendering.
- Parse and validate custom
.cub
configuration files. - Ensure clean memory management and Norm compliance.
git clone https://github.com/sbibers/cub3d.git
cd cub3d
To run the project, make sure you have the necessary dependencies installed:
- CMake (for building the project)
sudo apt-get install cmake
- MiniLibX (for graphics rendering)
- Install required libraries:
sudo apt-get install libx11-dev libxext-dev libmlx5-dev
- Install required libraries:
- GLFW (for window management)
sudo apt-get install libglfw3 libglfw3-dev
- OpenGL (for 3D rendering)
sudo apt-get install libopengl-dev
Note: Ensure you have all the necessary dependencies for your operating system. If you're using macOS, you can use Homebrew to install the necessary libraries.
make
./cub3D maps/good/your_map.cub
A .cub
map file contains:
- Texture paths
NO ./textures/north_texture.png SO ./textures/south_texture.png
- Floor and Ceiling colors
F 220,100,0 C 225,30,0
- 2D Map Grid
1
→ Wall0
→ Empty spaceN
,S
,E
,W
→ Player start position & orientationD
→ Door (Bonus)
Example
11111
10001
10N01
11111
Key | Action |
---|---|
W A S D |
Move player |
← → |
Rotate view |
ESC |
Exit game |
Close window | Cleanly exit |
✅ Raycasting-based 3D rendering
✅ Realistic 3D maze visualization
✅ Smooth window management (resizing, minimizing)
✅ Textures changing based on wall orientation (North, South, East, West)
✅ Customizable floor and ceiling colors
✅ Player movement using W
, A
, S
, D
keys
✅ View rotation using ←
→
arrow keys
✅ Interactive minimap overlay
✅ Doors that open and close (Bonus)
✅ Mouse-based point of view rotation
cub3D/
├── inc/ # Header files
├── libft/ # Custom C library
├── MLX42/ # MiniLibX library
├── maps/ # .cub map files
├── src/ # Project source files
├── textures/ # Wall textures
├── obj/ # Compiled objects
├── Makefile
└── README.md
👤 Salam Baybars
📍 42 Amman