Skip to content

zatrange/cub3D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cub3D 🎮

A 3D raycasting game engine inspired by Wolfenstein 3D, built in C using MLX42.

Gameplay


📖 About

cub3D is a 42 School project that challenges students to build a fully functional first-person 3D game engine from scratch using the raycasting technique — the same technique used in classic games like Wolfenstein 3D and the original DOOM.

The engine parses a custom .cub map file, renders textured walls in pseudo-3D, and handles player movement and collision detection — all without any game engine framework.


🖼️ Screenshots

Gameplay — First Person View

First Person Gameplay

Game Over Screen

You Lose Screen You win Screen


✨ Features

Mandatory

  • Raycasting engine rendering textured walls in real-time
  • Directional wall textures (North, South, East, West)
  • Configurable floor and ceiling colors via .cub map file
  • Smooth player movement (W / A / S / D)
  • Camera rotation (Left / Right arrow keys)
  • Clean exit on ESC or window close

Bonus

  • Minimap — top-left overview of the full map with player position
  • Door system — openable/closeable doors integrated into the map
  • Health system — hearts displayed in the HUD (top-right corner)
  • Animated weapon — first-person hand and weapon rendered on screen
  • Shadow / distance shading — walls darken realistically with distance
  • Multiple weapon skins — different player loadouts supported

🗺️ Map Format (.cub)

NO ./textures/north_wall.png
SO ./textures/south_wall.png
WE ./textures/west_wall.png
EA ./textures/east_wall.png

F 30,30,30
C 50,50,80

111111
100001
1000N1
100001
111111
Symbol Meaning
1 Wall
0 Empty floor
N/S/E/W Player spawn + facing direction
D Door (bonus)

Rules: the map must be fully enclosed by walls and be the last element in the file.


🛠️ Building

Prerequisites

  • cc (clang or gcc)
  • cmake (for MLX42)
  • glfw3 (sudo apt install libglfw3-dev on Ubuntu)
  • libdl, libpthread, libm

Build MLX42 first

cd mlx
cmake -B build
cmake --build build
cp build/libmlx42.a .
cd ..

Compile

# Mandatory version
make

# Bonus version
make bonus

🚀 Usage

./cub3D maps/your_map.cub

# Bonus
./cub3D_bonus maps/your_map.cub

Controls

Key Action
W A S D Move
Mouse Rotation
E Switch Weapons
R Reload
Shift Sprint
ESC Quit

⚙️ Technical Details

  • Rendering: DDA (Digital Differential Analysis) raycasting algorithm
  • Texturing: Per-column texture mapping with correct perspective
  • Shading: Distance-based shadow blending (shadow() function)
  • Graphics library: MLX42 (OpenGL/GLFW backend)
  • Language: C (C99), compiled with -Wall -Wextra -Werror

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors