Skip to content

Beicai91/Cub3D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cub3D

A first-person raycasting engine inspired by Wolfenstein 3D, developed in C using the MiniLibX graphical library.
The player can explore a 3D environment rendered from a 2D map, navigate around walls, through doors and rotate the camera in real time.

Installation

git clone
cd Cub3D
  • For version without mini-map and animated sprite
cd mandatory
make all

-For version with mini-map and animated sprite

cd bonus
make all

Usage

./cub3D map/map_simple.cub

Controls

W: Move forward
S: Move backward
A: Move left
D: Move right
Touchpad / mouse: Rotate camera
ESC: Quit the game

Dev features

  • Robust map parsing and validation
  • Custom raycasting engine
  • Real-time 3D rendering based on a 2D map
  • Smooth player movement and camera rotation
  • Mini-map to guide player movement
  • Animated sprite
  • Descriptive error handling

Tecnical notes

  • Raycasting calculates the distance from the player to the closest wall for each rendered column (projected wall slice).
    The Digital Differential Analyzer (DDA) algorithm is used to detect wall intersections by advancing the ray through the grid cell by cell and checking horizontal and vertical crossings until a wall is hit.
check-horizontal-intersection check-vertical-intersection
  • Wall scaling illustration Wall-scaling-illustration

  • Mouse movement updates the camera by tracking the latest and previous cursor positions.Each mouse movement creates a new node holding the latest cursor coordinates at the head of a linked list. The next node has the previous cursor coordinates. Two cursor coordinates are then compared to detect horizontal or vertical motion of player's view, which leads to update of the frame. A drawback of this approach is that it can produce memory leaks if the linked list grows unchecked.

Demo

Cub4D

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors