Skip to content

Overview

cub3D is a 42 graphics project written in C with MiniLibX. It renders a pseudo-3D first-person view from a 2D .cub map through a structured parsing, validation, and raycasting pipeline.

Project overview

`cub3D` is a C raycasting engine built around one `.cub` file, one runtime owner, and one frame loop

The project turns a 2D map into a pseudo-3D first-person view with MiniLibX. Parsing, validation, initialization, rendering, input, and cleanup are all part of one coherent startup-to-shutdown pipeline.

01
Codebase split

The repository is intentionally divided between the mandatory baseline and bonus extensions, while keeping one shared runtime model.

srcs/

Mandatory implementation

Base parsing, map validation, player setup, raycasting, input, frame drawing, and cleanup.

srcs_bonus/

Bonus extensions

Doors, sprites, HUD, levels, retro rendering, and bonus-aware no-op compatibility for baseline builds.

02
What the program does

The important overview is chronological. The engine does not “just raycast”: it first proves the configuration is safe, then enters rendering.

01 parse `.cub` read texture headers, color headers, and the map block
02 validate the map accepted symbols, one spawn, and enclosed playable space
03 initialize MLX window, frame image, textures, and graphics state
04 update input and movement rotation, collision-aware motion, and redraw scheduling
05 raycast and render one ray per column, wall hit, projection, and texture sampling
06 exit cleanly ordered resource teardown through the application cleanup path
03
Technical focus

The project is mostly about disciplined systems work: parsing, deterministic rendering, movement, memory, and separation of responsibilities.

parsing

robust header parsing, explicit rejects, and map validation gates

rendering

manual framebuffer writes, DDA determinism, and one present path per frame

movement

collision-aware motion, camera rotation, and tile-based spatial reasoning

lifecycle

predictable allocation, init, destroy, and cleanup ordering

separation

separate source groups and bonus modules, with some shared runtime coupling through compatibility layers

04
Core stack

These are the technologies and concepts that define the practical shape of this cub3D implementation.

CMiniLibXDDA raycastingBFS validation42 Norm
Reading stance

This guide stays implementation-oriented instead of drifting into generic theory.

Each page is meant to describe how this codebase behaves, including the mandatory path and the bonus layers. The goal is to explain concrete structure and runtime behavior rather than abstract cub3D concepts in isolation.

This repository includes both the mandatory implementation and the bonus extensions, documented as one coherent system rather than as a set of disconnected feature lists.

The most useful way to navigate the project is:

  1. understand the .cub input contract and map validation gates
  2. follow player initialization, input/movement updates, and DDA rendering
  3. then add bonus systems such as doors, sprites, HUD, and levels

This overview is implementation-oriented. It summarizes how this specific codebase is organized and how its runtime path is structured in practice.