Skip to content

Cub3D is a 42 school team project to create a dynamic view inside a 3D maze using raycasting in the style of Wolfenstein3D.

Notifications You must be signed in to change notification settings

Omarak9120/cub3d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screen-Shot-2022-04-02-at-18 04 30

Cub 3D

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

cub3d_record.mp4

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/omarak9120/cub3d.git

Git sync main

$ git clone
$ Make
$ valgrind --leak-check=full -q ./cub3d maps/rave.cub
$ and have fun with the game

Links:

About

Cub3D is a 42 school team project to create a dynamic view inside a 3D maze using raycasting in the style of Wolfenstein3D.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published