A 3D raycasting game engine inspired by Wolfenstein 3D, built in C using MLX42.
cub3D is a 42 School project that challenges students to build a fully functional first-person 3D game engine from scratch using the raycasting technique — the same technique used in classic games like Wolfenstein 3D and the original DOOM.
The engine parses a custom .cub map file, renders textured walls in pseudo-3D, and handles player movement and collision detection — all without any game engine framework.
- Raycasting engine rendering textured walls in real-time
- Directional wall textures (North, South, East, West)
- Configurable floor and ceiling colors via
.cubmap file - Smooth player movement (W / A / S / D)
- Camera rotation (Left / Right arrow keys)
- Clean exit on
ESCor window close
- Minimap — top-left overview of the full map with player position
- Door system — openable/closeable doors integrated into the map
- Health system — hearts displayed in the HUD (top-right corner)
- Animated weapon — first-person hand and weapon rendered on screen
- Shadow / distance shading — walls darken realistically with distance
- Multiple weapon skins — different player loadouts supported
NO ./textures/north_wall.png
SO ./textures/south_wall.png
WE ./textures/west_wall.png
EA ./textures/east_wall.png
F 30,30,30
C 50,50,80
111111
100001
1000N1
100001
111111
| Symbol | Meaning |
|---|---|
1 |
Wall |
0 |
Empty floor |
N/S/E/W |
Player spawn + facing direction |
D |
Door (bonus) |
Rules: the map must be fully enclosed by walls and be the last element in the file.
cc(clang or gcc)cmake(for MLX42)glfw3(sudo apt install libglfw3-devon Ubuntu)libdl,libpthread,libm
cd mlx
cmake -B build
cmake --build build
cp build/libmlx42.a .
cd ..# Mandatory version
make
# Bonus version
make bonus./cub3D maps/your_map.cub
# Bonus
./cub3D_bonus maps/your_map.cub| Key | Action |
|---|---|
W A S D |
Move |
Mouse |
Rotation |
E |
Switch Weapons |
R |
Reload |
Shift |
Sprint |
ESC |
Quit |
- Rendering: DDA (Digital Differential Analysis) raycasting algorithm
- Texturing: Per-column texture mapping with correct perspective
- Shading: Distance-based shadow blending (
shadow()function) - Graphics library: MLX42 (OpenGL/GLFW backend)
- Language: C (C99), compiled with
-Wall -Wextra -Werror



