Skip to main content

Overview

All configuration constants are defined in headers/cub3d.h. These control window settings, player behavior, entity properties, rendering parameters, and performance tuning.

Window Configuration

Window and display settings.
W_TITLE
string
default:"cub3d"
Window title displayed in the title bar.
#define W_TITLE "cub3d"
W_WIDTH
int
default:"1024"
Window width in pixels. Can be overridden at compile time.
#ifndef W_WIDTH
# define W_WIDTH 1024
#endif
Compile with custom width: make CFLAGS="-DW_WIDTH=1920"
W_HEIGHT
int
default:"768"
Window height in pixels. Can be overridden at compile time.
#ifndef W_HEIGHT
# define W_HEIGHT 768
#endif

Player Configuration

Player movement, camera, and interaction settings.

Movement

PLAYER_WALK_VELOCITY
double
default:"4.0"
Player walking speed in units per second.
#define PLAYER_WALK_VELOCITY 4.0
PLAYER_SPRINT_VELOCITY
double
default:"6.0"
Player sprinting speed in units per second (1.5x walk speed).
#define PLAYER_SPRINT_VELOCITY 6.0
PLAYER_WIDTH
double
default:"0.23"
Player collision box width in map units.
#define PLAYER_WIDTH 0.23
PLAYER_HEIGHT
double
default:"0.23"
Player collision box height in map units.
#define PLAYER_HEIGHT 0.23

Camera & Vision

PLAYER_FOV
double
default:"66.0"
Player field of view in degrees. Standard FOV similar to classic FPS games.
#define PLAYER_FOV 66.0
PLAYER_MOUSE_LOOK_VELOCITY
double
default:"20.0"
Mouse look sensitivity (degrees per pixel movement).
#define PLAYER_MOUSE_LOOK_VELOCITY 20.0
PLAYER_KEY_LOOK_VELOCITY
double
default:"180.0"
Keyboard look rotation speed in degrees per second.
#define PLAYER_KEY_LOOK_VELOCITY 180.0

Raycasting

PLAYER_RAYS_NO_HIT_LENGTH
double
default:"50.0"
Maximum ray distance when no wall is intersected.
#define PLAYER_RAYS_NO_HIT_LENGTH 50.0
Setting this too high impacts performance. Setting too low causes visual artifacts.
PLAYER_RAY_SUBRAYS
int
default:"5"
Number of sub-rays cast per screen column for improved hit detection.
#define PLAYER_RAY_SUBRAYS 5
Higher values improve accuracy but reduce performance.
PLAYER_RAY_HIT_ENTITIES_NUMBER
int
default:"5"
Maximum number of entities tracked per ray for shooting.
#define PLAYER_RAY_HIT_ENTITIES_NUMBER 5

Interaction

PLAYER_MAX_TARGET_DISTANCE
double
default:"1.2"
Maximum distance to interact with entities (doors, items, etc.).
#define PLAYER_MAX_TARGET_DISTANCE 1.2

Multiplayer

PLAYER_MAX
int
default:"4"
Maximum number of simultaneous players.
#define PLAYER_MAX 4
PLAYER_DEAD_RESET_DELAY
int
default:"2000"
Milliseconds before respawning a dead player.
#define PLAYER_DEAD_RESET_DELAY 2000

Character Configuration

Settings for NPCs and character entities.
CHARACTER_HIT_DELAY
double
default:"100.0"
Milliseconds of invulnerability after taking damage (prevents multi-hit).
#define CHARACTER_HIT_DELAY 100.0
CHARACTER_DEFAULT_MAX_HEALTH
int
default:"100"
Default maximum health for character entities.
#define CHARACTER_DEFAULT_MAX_HEALTH 100

Billboard Configuration

Settings for sprite-based entities.
BILLBOARD_WIDTH
double
default:"0.23"
Default width of billboard sprites in map units.
#define BILLBOARD_WIDTH 0.23
BILLBOARD_HEIGHT
double
default:"0.23"
Default height of billboard sprites in map units.
#define BILLBOARD_HEIGHT 0.23

Entity Configuration

General entity system settings.
INVENTORY_SIZE
int
default:"9"
Number of inventory slots per character.
#define INVENTORY_SIZE 9
struct s_character {
    // ...
    t_item *inventory[INVENTORY_SIZE];
    int inventory_index;  // Currently selected slot (0-8)
};
INVENTORY_SCROLL_DELAY
double
default:"0.5"
Minimum seconds between inventory slot changes (prevents accidental scrolling).
#define INVENTORY_SCROLL_DELAY 0.5

Wall Configuration

WALL_INTERACTION_DISTANCE
double
default:"2.0"
Maximum distance to interact with walls (for action prompts).
#define WALL_INTERACTION_DISTANCE 2.0

Door Configuration

DOOR_ANIMATION_FPS
int
default:"6"
Frame rate for door opening/closing animations.
#define DOOR_ANIMATION_FPS 6
Animation delay is calculated as: 1000 / DOOR_ANIMATION_FPS milliseconds per frame.

Map Configuration

Map parsing and defaults.
DEFAULT_MAP_PATH
string
default:"maps/hub.cub"
Map file loaded at startup.
#define DEFAULT_MAP_PATH "maps/hub.cub"
DEFAULT_AIR_TYPES
string
default:"0 \\t\\n\\v\\f\\r"
Characters representing walkable space in map files.
#define DEFAULT_AIR_TYPES "0 \t\n\v\f\r"
DEFAULT_WALL_TYPES
string
default:"1"
Characters representing solid walls in map files.
#define DEFAULT_WALL_TYPES "1"
DEFAULT_PLAYER_TYPES
string
default:"NSEW"
Characters representing player spawn points (N=North, S=South, E=East, W=West).
#define DEFAULT_PLAYER_TYPES "NSEW"
The character determines initial facing direction.

Rendering Configuration

Threading

CAMERA_THREADS
int
default:"4"
Number of parallel threads for raycasting.
#define CAMERA_THREADS 4
Optimal value depends on CPU core count. 4 threads works well for quad-core processors.

Minimap

MINIMAP_WIDTH_MULTIPLIER
double
default:"0.25"
Minimap width as a fraction of window width.
#define MINIMAP_WIDTH_MULTIPLIER 0.25
For 1024px window: minimap width = 256px
MINIMAP_HEIGHT_MULTIPLIER
double
default:"0.25"
Minimap height as a fraction of window height.
#define MINIMAP_HEIGHT_MULTIPLIER 0.25
For 768px window: minimap height = 192px

Performance Configuration

Frame Timing

FPS_LIMIT
int
default:"1000"
Target frames per second (uncapped by default).
#define FPS_LIMIT 1000
Set to 60 for VSync-like behavior: #define FPS_LIMIT 60
DELTA_TIME_START
float
default:"0.016f"
Initial delta time in seconds (equivalent to ~62.5 FPS).
#define DELTA_TIME_START 0.016f
Updated dynamically each frame based on actual timing.

Loading Screen

LOADING_MIN_LENGTH
int
default:"1000"
Minimum milliseconds to display loading screen.
#define LOADING_MIN_LENGTH 1000
Ensures loading screen is visible even for fast loads.

Asset Paths

Fonts

DEFAULT_FONT_PATH
string
default:"assets/fonts/IBM-VGA-8x16"
Default bitmap font for text rendering.
#define DEFAULT_FONT_PATH "assets/fonts/IBM-VGA-8x16"

Textures

PLACEHOLDER_IMAGE_PATH
string
default:"assets/textures/placeholder.bmp"
Fallback texture when assets fail to load.
#define PLACEHOLDER_IMAGE_PATH "assets/textures/placeholder.bmp"
LOADING_IMAGE_PATH
string
default:"assets/textures/loading.bmp"
Image displayed during map loading.
#define LOADING_IMAGE_PATH "assets/textures/loading.bmp"

Mathematical Constants

PI
double
default:"3.14159265359"
Pi constant for trigonometric calculations.
#define PI 3.14159265359

Compilation Flags

From Makefile:
CC = cc
CFLAGS = -Wall -Wextra -Werror -O3 -g

Platform-Specific Settings

Emscripten (WebAssembly)

#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#endif
When compiled with Emscripten, threading behavior is modified for browser compatibility.

macOS vs Linux

The Makefile automatically detects the platform and links appropriate frameworks:
LDLIBS += -framework OpenGL
LDLIBS += -framework AppKit
LDLIBS += -framework CoreAudio
# ... additional frameworks

Configuration Best Practices

Performance Tuning

  • High-end systems: Increase CAMERA_THREADS to 8, set FPS_LIMIT to 144+
  • Low-end systems: Reduce PLAYER_RAY_SUBRAYS to 3, limit FPS to 60
  • Web builds: Use 2-4 threads, lower FOV for better performance

Gameplay Tuning

  • Increase PLAYER_SPRINT_VELOCITY for faster-paced gameplay
  • Adjust CHARACTER_HIT_DELAY to balance combat difficulty
  • Modify INVENTORY_SIZE for more/fewer item slots

Visual Tuning

  • Wider PLAYER_FOV (90+) for more peripheral vision
  • Smaller BILLBOARD_WIDTH/HEIGHT for larger sprites
  • Adjust MINIMAP_*_MULTIPLIER for different minimap sizes

See Also

Build docs developers (and LLMs) love