Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42Cursus Cub3D developed by ryusupov and tkubanyc

cub3d demo

Project overview for Cub3D

GitHub last commit GitHub code size in bytes GitHub repo size GitHub language count GitHub contributors GitHub top language

🗣️ About

Welcome to cub3d, a journey into the world of raycasting, where 3D visuals come to life through fundamental computer graphics techniques. This project, created during my time at the prestigious 1337 School, dives deep into the intricacies of raycasting, enabling immersive environments with elegant simplicity. In cub3d, we explore the mechanics behind raycasting—a technique that projects rays from a virtual eye to map a 3D perspective onto a 2D screen. It’s the engine behind many early 3D games and remains relevant for understanding the basics of 3D rendering. This project builds a functional raycasting engine, transforming 2D map data into 3D spaces with walls, textures, and lighting effects, creating a compelling visual experience.

Steps to implement

According to the constraints imposed by the subject, the parsing was carried out in the following way :

1. Parsing

  • Texture path
    • Extract path to textures
    • Check if the path is valid or not
    • Check if the paths are named with NO, SO, EA, WE
  • RGB color codes
    • Extract the color codes
    • Check if the floor if F and Ceiling is C
    • Check if there are three color codes
    • Check if the codes are not more then 255 and not less than 0
  • Maap
    • Extract the map
    • Remove all the unnecessaary newlines
    • Check if the map is covered with walls from each side
    • Check if the map has only 0, 1 and (N, E, S, W)
    • Check if the empty spaces inside the map (space or tabs) are closed with walls and they're not reachable

Example of the valid map:

Horizontal line check

2. Graphical rendering:

  • Ray casting
    • Raycasting is a rendering technique used to create a 3D perspective of the game world. In this part, raycasting is implemented to calculate the angles of rays emanating from the player’s viewpoint. These rays are then cast onto the walls of the map, allowing the determination of the distance from the player to each wall. Based on these calculations, the engine determines the color of each wall to be rendered on the screen. Raycasting creates the illusion of depth and adds a sense of realism to the game environment.
  • Rendering the walls:
    • In this part of the project deals with rendering the game world, including walls, floors, and ceilings, onto the screen. By utilizing the map layout, the player’s position and direction, and the raycasting results, the engine determines the appropriate colors for each pixel on the screen. This information is then used to render the walls, creating a 3D perspective. Additionally, floors and ceilings are rendered to enhance the immersive experience. The rendering part gives life and visual representation to the game world.
  • Player Movement:
    • This part focuses on handling player movement and rotation within the game world. Keyboard input is used to control the player, allowing them to move forward, backward, and sideways. Additionally, the player can rotate left or right. The code monitors keyboard events and updates the player’s position and direction accordingly. This part enables the player to navigate and explore the game world.

Horizontal line check

Installation

  1. Clone the repository
  git clone https://github.com/YusuCoder/cub3D.git
  1. Open the repository and run this command:
  make

OR

  make bonus

Controls:

1, 2, 3 for changing the weapons
M to hide or show the minimap
W,A,S,D to move the player
T to set the timer
space to open the doors

Useful links:

About

my first 3d game

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages