Command Line Usage
Cub3D requires exactly one command-line argument: the path to a.cub map file.
Basic Syntax
The map file must have the
.cub extension and follow the Cub3D map format specification.Running with Example Maps
The Cub3D repository includes several example maps in themaps/ directory:
Available Example Maps
COME.cub
Minimal 3x3 test map - Perfect for testing basic functionality
DOOMGUY.cub
Medium-sized map with multiple rooms and corridors
Dommed.cub
Complex layout testing advanced map features
DOOMSLAYER.cub
Large map with intricate room design
Command-Line Validation
Cub3D performs strict validation of command-line arguments before attempting to load a map.Argument Count Validation
The program requires exactly 2 arguments (program name + map file):Empty Argument Validation
File Extension Validation
The map file must have a.cub extension:
Map File Validation
After command-line validation, Cub3D validates the map file contents:File Name Requirements
Fromutils.c:15-36, the validation checks:
- Minimum length: Filename must be at least 5 characters (name +
.cub) - Extension: Must end with
.cub - Printable characters: Filename must contain only printable characters
File Access Validation
The program attempts to open the map file:Initialization Process
When you run Cub3D successfully, the following initialization occurs:Parse map attributes
The program reads texture paths, floor color, and ceiling color from the map file:
Error Messages Reference
Here are the common error messages you might encounter when running Cub3D:| Error Message | Cause | Solution |
|---|---|---|
| ”Debes introducir dos argumentos por terminal” | Wrong number of arguments | Provide exactly one map file: ./cub3d map.cub |
| ”Argumento vacio, especifica un mapa” | Empty string argument | Provide a valid file path |
| ”El mapa tiene que acabar en .cub” | Wrong file extension | Use a .cub file extension |
| ”Tiene que tener nombre y extension .cub” | Filename too short | Filename must be at least 1 character + .cub |
| ”El mapa no se ha podido abrir” | File doesn’t exist or no permissions | Check file exists and is readable |
| ”Error: Empty map” | Map file is empty | Add valid map content |
| ”Map is not closed” | Map has holes or isn’t surrounded by walls | Fix map boundaries |
| ”Should have only one player…” | Multiple players or invalid characters | Ensure exactly one player (N/S/E/W) |
| “Error cargando textura” | Texture file not found | Verify texture paths in map file |
Runtime Information
Window Specifications
When Cub3D runs successfully, it creates a window with these specifications:- Width: 1732 pixels
- Height: 1000 pixels
- Title: The map filename (without path and extension)
Player Initialization
Frommain.c:51-62, the player is initialized at:
- SIZE: 30 pixels per map cell (defined in
cub3.h:33) - speed: 1 pixel per frame
- Initial position: Center of the player’s starting cell
- Initial direction: Based on player character (N/S/E/W)
Rendering
The game renders at the maximum frame rate your system allows, driven by the MiniLibX event loop:- Clears the image buffer
- Performs raycasting for each screen column (1732 rays)
- Draws textured walls with proper perspective
- Updates the window display
Exiting the Program
There are multiple ways to exit Cub3D:ESC Key
Press the ESC key to close the window and exit gracefully
Window Close
Click the window’s close button (X) to exit
Next Steps
Now that you know how to run Cub3D, learn how to control the player:Controls
Master the keyboard controls for movement and camera rotation