Skip to content

tsimitop/cub3D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸงŠ๐ŸŽฎ Cub3D

Cub3D is the second team project in the 42 core curriculum (partner->Clemens). It is a simplified 3D graphics engine based on raycasting, inspired by Wolfenstein 3D. This project aims to deepen our understanding of 3D rendering, vector math, and event-driven programming using the MLX graphics library. Screenshot 2025-07-07 at 1 07 24โ€ฏPM


๐Ÿ“Œ Table of Contents


๐Ÿง  Project Overview

Cub3D is a raycasting-based first-person 3D engine. It renders a 2D map in a pseudo-3D view using minimal graphical primitives. The player can navigate through a maze with textures applied to walls and floors, mimicking depth and perspective.

This project teaches:

  • Basics of raycasting (DDA algorithm)
  • Vector math and trigonometry
  • Real-time rendering and game loops
  • Handling player input and collisions
  • Texture mapping

๐Ÿงฉ Features

  • โœ… Raycasting engine (DDA algorithm)
  • โœ… Player movement & rotation
  • โœ… Wall collision detection
  • โœ… Texture rendering for walls
  • โœ… Minimap
  • โœ… Door mechanics
  • โœ… Mouse support
  • โœ… Sprite rendering (gif walls and doors)
  • โœ… Customizable settings

Minimap

  • Activate/deactivate minimap (press m). Some settings are visible in the minimap so make sure to have it activated when you check them out for the first time.
Screenshot 2025-07-07 at 1 24 52โ€ฏPM

Door mechanics

  • Open/close door (press spacebar). Doors are visible in the minimap as black tiles if opened and as white if closed. In the config they are set as 2 if closed and as 3 if opened.
  • Door on the right is closed.
Screenshot 2025-07-07 at 1 15 51โ€ฏPM - Door on the right is open. Screenshot 2025-07-07 at 1 16 11โ€ฏPM

Mouse support

  • Activate/deactivate mouse (press v). Check out the incredible message that's printed in your terminal after pressing "v". While activated you can turn left/right with your mouse.
Screenshot 2025-07-07 at 1 34 59โ€ฏPM Screenshot 2025-07-07 at 1 35 07โ€ฏPM

Sprite rendering

Use gif files in the config file to check out moving walls and doors. If the gif is very big the program will be a bit slow (rickgif is the slowest).

Customizable settings

  • Press G to activate a settings selection in the terminal of the running program. To select one press left Shift and scroll with your mouse. The selected setting will be light green and can be customized using the mouse wheel.
Screenshot 2025-07-07 at 1 24 48โ€ฏPM Screenshot 2025-07-07 at 1 25 05โ€ฏPM Screenshot 2025-07-07 at 1 25 11โ€ฏPM Screenshot 2025-07-07 at 1 25 43โ€ฏPM copy Screenshot 2025-07-07 at 1 25 41โ€ฏPM Screenshot 2025-07-07 at 1 25 43โ€ฏPM

๐Ÿš€ Getting Started

๐Ÿ›  Compile

make

๐Ÿƒ๐Ÿฝโ€โ™€๏ธ Run the game

./cub3D maps/select_a_map.cub

You can find the valid maps inside the maps directory. You can also attempt making your own map.


๐Ÿ•น Controls

  • Key Action
  • W / โ†‘ Move forward
  • S / โ†“ Move backward
  • A Strafe left
  • D Strafe right
  • โ† / โ†’ Turn left/right
  • ESC Exit game
  • Mouse look if enabled with v during play.

๐Ÿ—‚ Map Format

  • The map must be surrounded by walls (1).
  • Player start position must be one of the following:
    • N, S, E, or W.
  • The following identifiers are mandatory:
    • NO, SO, WE, EA โ€“ Wall textures
    • Floor and Ceiling RGB colors
  • DO for door is optional.
  • Use 2 for a closed door, 3 for an open door.

Legend:

Symbol Meaning
'space' Nothing/Space
1 Wall
0 Empty space
2 Closed door
3 Open door
N/S/E/W Player starting position
NO images/DEBUG/North.png
SO images/DEBUG/South.png
WE images/DEBUG/Westh.png
EA images/DEBUG/Easth.png
DO images/DEBUG/Doorh.png
F 220,100,0
C 225,30,0

111111
100001
1000N1
100001
111111
  • DO for door is optional. NO, SO, WE, EA are mandatory.
  • Map must be surrounded by walls (1).
  • Player start position: N, S, E, or W.
  • Floor/Ceiling RGB colors and wall textures are mandatory.
  • 2 for a closed door, 3 for an open door.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published