Skip to content

This project is inspired by the world-famous Wolfenstein 3D game, which was the first FPS ever

Notifications You must be signed in to change notification settings

iLucasPires/42-Cub3D

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cub3D

Cub 3D

Maze project using raycasting, with minilibx. Emulating FPS Wolfenstein game (1992)

Definitions / Infos:

  • Raycasting is a rendering technique to create a 3D perspective in a 2D map.
  • Raycasting is not the same as raytracing!
    • Raycasting is a fast semi-3D technique that works in realtime even on 4MHz graphical calculators.
    • while raytracing is a realistic rendering technique that supports reflections and shadows in true 3D scenes, and only recently computers became fast enough to do it in realtime for reasonably high resolutions and complex scenes.
  • DDA - The Digital Difference Analyzer(DDA) algorithm is used to draw lines on a screen in an incrementally. The algorithm is called the Digital Difference Analyzer because it interpolates based on the difference between the start and end points. The algorithm itself is very easy to understand and implement.
  • Ray Casting:
    1. Walls are always at 90° angle with the floor.
    2. Walls are made of cubes that have the same size.
    3. Floor is always flat.
  • FOV - Field of View The player should be able to see what is in front of him/her. For this, we will need to define a field of view (FOV)
  • "To put the player inside the world, we need to define the player’s X coordinate, the player’s Y coordinate, and the angle that the player is facing to. These three attributes forms the 'point of view' of the player."
  • Fisheye Effect: The fisheye effect is an effect you see if you use the real distance, where all the walls become rounded, and can make you sick if you rotate.

Technical Details:

  • DDA Will handle the "hit" in wall, looking the intersections of ray until hit the wall. This framework will give to us what block was hited, not the distance If this was handled by looking for a fixed distance until the wall, we are not able to get a good design.
  • DDA is able to identify block to block where the ray will pass (x or y)
  • 0.66 is a good size in FPS games (Size of plane)
  • Formula: Dir + Plane + Multiplier (-1 a 1)

Images:

Distance to wall:

Distance to wall

Calculating heading:

Calculating heading

Pythagoras:

pythagoras

More information:

  • Libft allowed.
  • GetNextLine allowed.
  • Folder structure apply (managed by Makefile).
  • No leaks are allowed.
  • Norma must be run.

To run:

$ git clone --recursive https://github.com/rlinsdev/42-Cub3D.git
# or
$ git clone https://github.com/rlinsdev/42-Cub3D.git
$ git submodule update --init --recursive

Git sync main

$ git checkout main
$ git pull
$ git checkout validator
$ git merge main
$ git push

Links:

About

This project is inspired by the world-famous Wolfenstein 3D game, which was the first FPS ever

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.5%
  • Makefile 2.5%