A 3D rendering engine inspired by Wolfenstein 3D
Project developed as part of the 42 Paris curriculum
Cub3D is a 3D engine based on the raycasting technique, the same technology used in the legendary Wolfenstein 3D. This project transforms a 2D map into an immersive 3D experience through dynamic collision management and custom texture application.
Raycasting simulates a 3D view by casting rays from the player's position to calculate distances to walls, creating an illusion of depth without requiring a real 3D engine.
- โก Real-time Raycasting: Generates a smooth 3D view from a 2D map
- ๐จ Texture System: Custom texture application for each direction (North, South, East, West)
- ๐ Configurable Colors: Customizable floor and ceiling via RGB
- ๐ฏ Collision Detection: Precise collision system for realistic navigation
- ๐งญ Smooth Navigation: Optimized movement and rotation
- ๐บ๏ธ Interactive Mini-map: Real-time player position display
- ๐ Debug Mode (F3): Displays debugging information (FPS, position, direction)
- ๐ Dynamic Zoom: Mini-map zoom level control
- ๐ Performance Display: Real-time performance monitoring
- Language: C (42 Standard)
- Graphics Library: MiniLibX
- Build System: GNU Make
- Compilation: GCC with flags
-Wall -Wextra -Werror - Mathematics: math.h library for trigonometric calculations
Make sure you have the following dependencies installed on your Linux system:
# C Compiler
sudo apt-get install gcc make
# MiniLibX Dependencies
sudo apt-get install libx11-dev libxext-dev libbsd-dev# Clone the repository
git clone https://github.com/ftTower/Cub3D.git
cd Cub3D
# Compile MiniLibX
make minlibx
# Compile the project
make
# Run the program with a map
./cub3d maps/VanGogh.cubmake bonus # Compile with bonus features (if available)
make clean # Remove object files
make fclean # Remove object files and executable
make re # Fully recompile the project./cub3d <path_to_map.cub># Van Gogh Map (recommended)
./cub3d maps/VanGogh.cub
# Basic Map
./cub3d maps/file.cub| Key | Action |
|---|---|
W / โ |
Move Forward |
S / โ |
Move Backward |
A |
Strafe Left |
D |
Strafe Right |
| Key | Action |
|---|---|
โ |
Rotate Left |
โ |
Rotate Right |
| Key | Action |
|---|---|
M |
Show/Hide Mini-map |
F3 |
Enable/Disable Debug Mode |
+ |
Zoom In Mini-map |
- |
Zoom Out Mini-map |
ESC |
Exit Program |
The configuration file defines the game environment. It must contain:
NO ./path/to/north_texture.xpm
SO ./path/to/south_texture.xpm
WE ./path/to/west_texture.xpm
EA ./path/to/east_texture.xpm
F 220,100,0 # Floor
C 225,30,0 # Ceiling
111111111111
100000000001
101100000001
100000N00001
111111111111
0: Empty space (navigable)1: WallN/S/E/W: Player starting position and orientation- N: North
- S: South
- E: East
- W: West
- โ
The map must be surrounded by walls (
1) - โ Only one player must be present
- โ All texture paths must be valid
- โ Colors must be in RGB format (0-255)
- โ Empty spaces must be closed (no openings to the void)
See full example: VanGogh.cub
NO ./maps/textures/VanGogh/north.xpm
SO ./maps/textures/VanGogh/south.xpm
WE ./maps/textures/VanGogh/west.xpm
EA ./maps/textures/VanGogh/east.xpm
F 184,113,39
C 51,153,255
111111111111111111111111
100000000011000000000001
101100000111000000000001
100100000000000000000001
111111111011000001110001
100000000011000001110001
111111111111111111111111cub3d/
โโโ src/ # Main source code
โ โโโ init/ # Initialization and parsing
โ โ โโโ config.c # Configuration parsing
โ โ โโโ map.c # Map parsing
โ โ โโโ map_parse.c # Map validation
โ โโโ raycasting/ # Rendering engine
โ โ โโโ raycasting.c # DDA Algorithm
โ โ โโโ textures.c # Texture management
โ โ โโโ raytures.c # Texture application
โ โโโ loop/ # Game loop
โ โ โโโ game.c # Main loop
โ โ โโโ key.c # Event handling
โ โโโ img/ # Graphics management
โ โ โโโ img.c # Image manipulation
โ โ โโโ drawing.c # Drawing functions
โ โ โโโ put_string.c # Text display
โ โโโ main.c # Entry point
โ โโโ free.c / free2.c # Memory management
โ โโโ utils.c / utils2.c # Utility functions
โโโ ReFile/ # Parsing library
โ โโโ gnl/ # Get Next Line
โ โโโ src/ # File utilities
โโโ includes/ # Headers
โ โโโ cub3d.h # Definitions and structures
โโโ maps/ # Test maps
โ โโโ textures/ # XPM Textures
โโโ assets/ # Resources (screenshots)
โโโ Makefile # Compilation
- Digital Differential Analyzer (DDA): Raycasting algorithm for intersection detection
- Memory Management: Clean allocation and deallocation of resources
- Event Loop: Rendering loop and MiniLibX event handling
- Texture Mapping: Projection of 2D textures onto walls
- Collision Detection: Wall collision detection
Developed by @ftTower
โญ If you liked this project, feel free to give it a star! โญ


