Skip to content

charlydev42/cub3d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧱 cub3D

cub3D is a project inspired by the classic Wolfenstein 3D game engine. The goal is to build a basic 3D raycasting engine from scratch using the MiniLibX graphics library. It’s a great introduction to graphics programming, raycasting, and game loop logic, and serves as a foundation to understand how early 3D engines were built.


🎮 Project Overview

Using a .cub map file as input, cub3D renders a 3D environment from a first-person perspective. It includes texture rendering, player movement, collision detection, and keyboard input handling.

The project is entirely written in C and uses MiniLibX (a simple X11 wrapper) to handle window management and drawing.


🧠 Educational Objectives

  • Raycasting (2D grid-based projection for 3D effect)
  • Game loop and rendering cycle
  • Texturing walls based on distance and perspective
  • Real-time input handling (keyboard events)
  • Map parsing and validation
  • Efficient memory and error management in C

⚙️ Compilation

Clone the repo and run:

make

This will:

  • Compile all source files in srcs/
  • Create object files in the obj/ directory
  • Build the final executable: cub3D

To clean up object files:

make clean

To remove everything including the executable:

make fclean

To recompile everything from scratch:

make re

🚀 Launching the Game

Run the program with a valid .cub map file:

./cub3D path/to/map.cub

Make sure your map includes:

  • Wall textures for each direction (N, S, E, W)
  • Floor and ceiling colors (RGB)
  • A valid layout (closed map, single player position)

🎨 Features

  • First-person 3D projection using raycasting
  • Textured walls with directional rendering
  • MiniMap overlay
  • Basic keyboard input (WASD movement + rotation)
  • Collision detection (no walking through walls)
  • Window rendering using MiniLibX (Linux)
  • Custom map parser and validation

🛠️ Dependencies

  • MiniLibX (provided in the repo under mlx/)
  • Linux system with X11 (libXext, libX11, libm)

✏️ Sample Map Format

NO ./textures/north.xpm
SO ./textures/south.xpm
WE ./textures/west.xpm
EA ./textures/east.xpm
F 220,100,0
C 225,30,0

111111
100001
1000N1
111111

Legend:

  • 1 = Wall
  • 0 = Empty space
  • N, S, E, W = Player starting position and direction

Feel free to fork, contribute, or use this as inspiration for your own 3D projects!

git clone https://github.com/cgermain78/cub3d.git
cd cub3D
make
./cub3D maps/example.cub

About

Cub3D aims at creating dynamic view inside a 3D maze using raycasting in the style of Wolfenstein3D in C.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors