Skip to content

Pixyde/cub3d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧱 cub3D

Raycasting engine project developed as part of the 42 curriculum. A 3D rendering system inspired by the classic Wolfenstein-style engines 🕹️


User

Zcadinot & Dedavid


🎯 Objective

cub3D consists of building a minimal 3D graphics engine using the raycasting technique.

From a 2D map described in a .cub configuration file, the program renders a first-person perspective environment.

The goal is to understand low-level graphics programming, mathematical projection, memory management, and clean architecture in C.


🧠 Core Concepts

  • 📐 Raycasting algorithm
  • 🗺️ Map parsing and validation
  • 🧮 Collision detection
  • 🎨 Wall texturing
  • 🌌 Floor and ceiling rendering
  • 🎮 Player movement handling
  • 🧵 Strict memory management
  • ❌ Complete error handling

🗂️ .cub Configuration File Format

The configuration file contains:

Textures

  • NO → North wall texture
  • SO → South wall texture
  • WE → West wall texture
  • EA → East wall texture

Colors

  • F R,G,B → Floor color
  • C R,G,B → Ceiling color

Map

The map is composed of:

  • 1 → Wall
  • 0 → Empty space
  • N, S, E, W → Player starting position and orientation

The map must:

  • Be fully enclosed by walls
  • Contain exactly one player
  • Contain only valid characters

🏗️ Project Architecture

structure:

src/
  parsing/
  raycasting/
  rendering/
  movement/
  utils/
include/
textures/
maps/

Architecture principles:

  • Clear separation of responsibilities
  • Small, focused functions
  • High readability
  • Robust error handling
  • Easy maintainability

⚙️ Compilation

make

Cleaning rules:

make clean
make fclean
make re

▶️ Usage

./cub3D maps/map.cub

🎮 Controls

  • W → Move forward
  • S → Move backward
  • A → Move left
  • D → Move right
  • / → Rotate camera
  • ESC → Exit program

🛡️ Error Handling

The program systematically checks:

  • Argument validity
  • .cub file format
  • Map enclosure
  • Unique player presence
  • Texture accessibility
  • RGB value correctness
  • Memory allocation failures
  • Graphics library initialization errors

On any error:

  • All allocated memory is freed
  • The program exits cleanly

🚀 Bonus Features (if implemented)

  • 🖱️ Mouse rotation
  • 🚪 Animated doors
  • 👾 Sprites
  • 🔫 Animations
  • 🧱 Mini-map

📚 Technologies

  • C language
  • MiniLibX graphics library
  • 42 coding standard

🧩 Skills Developed

  • Computational geometry
  • Real-time rendering logic
  • Memory management mastery
  • Robust parsing techniques
  • Software architecture design
  • Graphics debugging and optimization

✍️ Author

Developed as part of the 42 school curriculum.


🏁 Conclusion

cub3D is a deep dive into low-level graphics programming.

It combines mathematics, structured architecture, strict memory discipline, and algorithmic precision to create a minimal yet powerful 3D rendering engine.

🔥 A challenging and highly formative project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors