Welcome to the Cub3D project! This project was developed together with Mehmet Nasim Yılmaz as part of our educational process in 42 schools. Cub3D is a graphics application based on ray-casting technique that transforms 2D maps into an immersive 3D experience. Our goal is to transform a simple 2D maze map into an immersive 3D environment that the player can explore in real time.
This project aimed to give an in-depth understanding of graphics programming, user interactions and performance optimization. Cub3D offers a classic “Wolfenstein 3D” style gameplay with textured walls with different orientations, dynamic lighting effects and intuitive player controls. Players can freely navigate the environment with WASD and arrow keys, exploring the mysterious labyrinth while trying to reach their goals.
Click the image above to download the demo video!
cd Desktop
git clone git@github.com:e-kose/cub3d.git cub3d
cd cub3dFor Linux install X11
sudo apt install libx11-dev libxext-dev libxxi-dev libxrandr-dev libxpm-dev libxmu-dev libxi-dev libxcursor-dev libxt-dev libbsd-dev libjpeg-dev libpng-dev libtiff- dev libgif-dev libopenexr-dev libmpc-dev libgmp-dev libgmp-dev libmpfr-dev libgomp1 libgomp-plugin-nvptx libgomp1-plugin-nvptx libatomic1 libquadmath0 libpgm-dev libssl-devTo compile the program, run:
makeTo run the program, use one of the following commands:
./cub3d map/kvp.berIn this project we used the MLX library, a basic graphics library for window graphics management. MLX provided us with the tools and functions necessary to create and render 3D environment, manage user input and render graphic elements effectively.
Our project harnesses the power of ray casting to transform a 2D map into a 3D wonderland. By skillfully manipulating rays, we bring depth and dimension to what was once a flat surface. This technique allows us to create the illusion of 3D environments in real time.
We take our project one step further by adding textures to the walls. Each main direction (north, south, east and west) is decorated with its own unique texture, enhancing the immersive experience. The variety of textures adds realism and depth to our virtual world.
Players can explore the 3D environment with intuitive controls:
Wfor forward movementSfor backward movementAfor left movementDfor right movement- Use the left and right arrow keys to change the viewpoint.
These controls provide a fluid and engaging user experience that facilitates discovery.
We've taken care to ensure robust error handling. Our project can elegantly handle various error scenarios that can result from an invalid map. Whether it's an unclosed border or missing items, we've got it covered. Users can expect a stable and reliable experience.
We used the following resources to develop this project:
- Ray-Casting Tutorial (Lode's Computer Graphics Tutorial)
- Ray-Casting Tutorial (Permadi)
- YouTube Video: Raycasting Engine Explained
- Raycasting Engine Tutorial by Pikuma
- Medium Article: Raycasting in Cub3D - A Practical Guide
These resources gave us a deep understanding of ray casting and the basics of 3D graphics. In particular, we used these guides to optimize ray casting algorithms and make the game world more immersive.
