Overview
Cub3D is a first-person 3D maze game written in C that uses a DDA (Digital Differential
Analysis) raycasting engine to render a pseudo-3D perspective from a 2D map. Navigate
textured corridors, open animated doors, and explore levels defined in .cub
configuration files — all inspired by Wolfenstein 3D.
Built as a 42/Hive Helsinki team project using the MLX42 graphics library, the engine includes a minimap, sprite rendering, mouse look, and frame-rate independent animations.
Key Features
- DDA raycasting with fish-eye correction and UV texture mapping
- Distinct textures for North, South, East, and West walls
- Animated doors — press
Eto open/close with smooth alpha-blended fade - Sprite rendering with distance-based sorting
- Minimap with automatic scaling to fit any map size (200×200 px)
- Mouse look with 360° camera rotation (toggle with
M) - 9-point collision detection and flood-fill map validation
- Delta-time normalisation for frame-independent animation speed
Tech Stack
My Role
This was a two-person project. I owned the map parser — reading and validating
.cub configuration files including flood-fill map validation. On
the rendering side I implemented the minimap, mouse-look rotation, and the
animated door system including the alpha-blending logic for the open/close transition.
Challenges & Learnings
The most complex part was the door animation system: doors needed to be partially
transparent during opening/closing, which required alpha-blending pixels on the fly
and deciding when a ray should pass through versus stop at a door less than 95% open.
Implementing a flood-fill map validator to guarantee no walkable void space leaks
was also essential to catch malformed .cub maps before rendering.