cub3d is a first-person game written in C using MLX42. The project focuses on ray casting, map parsing, movement/collision, and bonus gameplay systems implemented in a clean modular structure.
- Ray-casting renderer (walls, floor, ceiling, shading)
- Strict
.cubparser and map validation - Textured walls (XPM42 assets)
- Player movement, jump, and collision handling
- Bonus systems: keys, doors, minimap, sprites.
- Move:
WASD - Look:
MouseandArrow Keys - Jump:
Space - Run:
Shift - Open door:
E - Toggle minimap:
M - Exit:
Esc
include/ headers (`cub3d.h`)
src/parser/ config/map parser and validation
src/game/ core loop, movement, ray cast, draw pipeline
src/bonus/ doors, keys, minimap, sprites, checkpoint logic
src/error/ error handling helpers
assets/ XPM42 textures and sprites
maps/ `.cub` maps (default: `maps/default.cub`)
The renderer casts one ray per screen column:
- Build camera ray from player direction + camera plane.
- Use DDA grid stepping until a wall tile is hit.
- Compute perpendicular distance to avoid fish-eye distortion.
- Project wall slice height on screen.
- Sample texture coordinates and draw vertical stripe.
- Draw floor/ceiling and apply distance-based shading.
Core files:
src/game/fn_game_ray.csrc/game/fn_game_wall_loop.csrc/game/fn_game_wall_draw.csrc/game/fn_game_floor_draw.c
Mandatory build:
make
./cub3D maps/wall.cubBonus build:
make bonus
./cub3D_bonus maps/default.cubmake clean
make fclean