Back to projects

42 project

Cub3D

A rendering engine inspired by Wolfenstein 3D to explore raycasting, textures and 3D representation.

Stack

  • C
  • Raycasting
  • MiniLibX
  • Graphics

Skills gained

  • Implementing a raycasting renderer
  • Working with textures, colors and projections
  • Parsing and validating a game map
  • Understanding the mathematical foundations of pseudo-3D rendering

Links

Cub3D is a graphics project inspired by early FPS games like Wolfenstein 3D. The goal is to create a pseudo-3D rendering from a 2D map, using raycasting to compute walls, distances, textures and perspective.

01 — Map

A world in two dimensions.

The project starts with reading and validating a 2D map. This map becomes the foundation of the world displayed on screen: walls, spaces, player position and initial orientation all need to be interpreted correctly.

Illustration of a 2D map used to generate a pseudo-3D world
Fig. 01
It all starts with a character grid pretending to be a game level.

02 — Raycasting

Casting rays.

Raycasting simulates a 3D view from a 2D environment. Each ray measures the distance to the nearest wall, then that distance is converted into the height of a vertical column drawn on screen.

Illustration of raycasting principles in a graphics engine
Fig. 02
Technically not real 3D.

03 — Rendering

Building the illusion.

Textures, colors, collisions and movement make the rendering feel more alive. Cub3D helped me better understand the relationship between mathematics, visual perception and low-level graphics programming.

Illustration of a pseudo-3D rendering with textures
Fig. 03
When math, pixels and a bit of stubbornness become a 3D corridor.