🎮 Welcome to Cub3d! 🎮
Cub3d is a project inspired by the classic game Wolfenstein 3D, where you navigate through a maze-like environment from a first-person perspective. It's part of the 42 curriculum and aims to introduce students to the fundamentals of raycasting, graphics rendering, and game development.
- The project must be written in C.
- Usage of external libraries such as OpenGL is prohibited.
- The graphics rendering must be implemented using the MiniLibX, a simple graphic library provided by 42.
- It should display different wall textures that vary depending on which side the wall is facing (North, South, East, West), as well as set the floor and ceiling colors to two different ones;
- Allowed functions: open, close, read, write, printf, malloc, free, perror, strerror, exit, all functions of the math and MinilibX libraries;
Cub3d employs raycasting to render the 3D environment. The map is represented as a grid of cells, containing information about the walls and player position. Raycasting involves casting rays from the player's perspective to simulate the 3D effect, calculating intersections with walls, and rendering the scene accordingly.
Key components of Cub3d include:
- Parsing map files to extract relevant information.
- Implementing raycasting algorithms to render the scene.
- Handling player movement and collisions.
- Rendering textures and sprites.
- First download Minilibx, rename its directory to 'mlx' and add it to the root directory of the cub3d project;
- To compile Cub3d, run
make
ormake bonus
(if you want to try the bonus version); - Then run it as such
./cub3d <maps/map.cub>
or./cub3d_bonus <maps/map.cub>
. Replacemaps/map.cub
with the path to your custom map file. You can find sample map files in themaps
directory;
- The left ⬅️ and right ➡️ arrow keys of the keyboard allow you to look left and right in the maze;
- The W and S keys allow you to move forward or backward in a straight line;
- The A and D keys allow you to move left or right in a straight line;
- The Esc key allows you to exit the game cleanly (so does clicking on the red cross on the window’s frame);
NO textures/tech_1.xpm
SO textures/tech_2.xpm
WE textures/tech_3.xpm
EA textures/tech_4.xpm
F 95,95,95
C 113,211,244
1111111111111111111111111
1000000000110000000000001
1011000001110000000000001
1001000000000000000000001
111111111011000001110000000000001
100000000011000001110111100111111
11110111111111011100000010001
11110111111111011101010010001
11000000110101011100000010001
10000000000000001100000010001
10000000000000001101010010001
11000001110101011111011110N0111
11110111 1110101 101111010001
11111111 1111111 111111111111
Screencast.from.04-04-2024.02.35.06.PM.webm
-
Personal page for notes;