Cub3D is the final C project in the 42 curriculum, where we implemented a basic raycasting engine inspired by Wolfenstein 3D.
This was a group project:
- Raycasting & Graphics: Josรฉ Maria Lebre
- Parsing & Map Handling: mtavares
The project took around 2 months to complete, using the original textures from Wolfenstein 3D.
One of the biggest challenges was correctly mapping the X-coordinate of a texture onto a wall.
๐ To see the project subject, click here!
Recording.2023-05-10.020203.mp4
Recording.2023-05-10.020825.mp4
Install MLX:
sudo apt-get install gcc make xorg libxext-dev libbsd-dev
git clone https://github.com/42Paris/minilibx-linux.git && cd minilibx-linux && ( [ -f ./configure ] && ./configure || true ) && make && sudo cp libmlx.a /usr/local/lib/ && [ -f libmlx_$(uname -m).a ] && sudo cp libmlx_$(uname -m).a /usr/local/lib/ || true && sudo cp mlx.h /usr/local/include/ && sudo mkdir -p /usr/local/man/man3 && sudo cp man/man3/mlx*.1 /usr/local/man/man3
Download the rep:
git clone https://github.com/jlebre/42Cub3d.git
cd 42Cub3d/
make
To run the game:
./cub3d "map"
Available maps:
./cub3d basic.cub
./cub3d info.cub
You can create custom maps as long as they follow the constraints in The Assignment section.
To compile and run basic.cub
in one command:
make a
The goal was to build a 3D labyrinth game with first-person view, inspired by Wolfenstein 3D.
- Use MiniLibX for rendering.
- Smooth window management (switching, minimizing, etc.).
- Textured walls that vary based on orientation (N, S, E, W).
- Custom floor & ceiling colors.
- Keyboard controls:
W, A, S, D
โ Move playerโ, โ
โ Rotate viewESC
โ Exit game
- Clicking the windowโs close button should properly exit.
- Parse
.cub
files for game settings & map layout. - The map must be enclosed by walls (
1
for walls,0
for empty space,N/S/E/W
for player spawn position).
Example of a valid .cub
map:
111111
100101
101001
1100N1
111111
NO ./path_to_north_texture
SO ./path_to_south_texture
WE ./path_to_west_texture
EA ./path_to_east_texture
F 220,100,0
C 225,30,0
If any error is found in the configuration file, the program must exit with:
Error
[Description of the issue]
โ๏ธ Working compass
โ๏ธ Minimap FOV matches actual player vision
โ๏ธ Pause menu (P
key)
โ๏ธ Toggle minimap (M
key)
โ๏ธ Lives system (press -
to lose a life, game stops at 0)
We completed 3 out of 5 possible bonus features:
โ๏ธ Wall collisions
โ๏ธ Mini-map system
โ๏ธ Move FOV with mouse
This was one of the most enjoyable projects Iโve worked on! Seeing visual progress made it extra rewarding.
This might be my favorite project so far, and Iโd love to add more features in the future. ๐