diff --git a/README.md b/README.md index 8a3e001..a45934b 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,34 @@ ## Description -cub3D is a graphical project inspired by early 3D games such as *Wolfenstein 3D*. -Its goal is to render a 3D representation of a maze from a 2D map using the **raycasting technique**, written entirely in C using MLX graphics library. +**cub3D** is a graphical programming project inspired by the classic game *Wolfenstein 3D*, +one of the first First-Person Shooters ever created. -This project renders a 3D view of a 2D map described in a '.cub' file. -The player can move inside the map, rotate the camera and see textures walls, floor and ceiling. +The goal of this project is to build a **real-time 3D representation of a maze** from a **2D map**, +using the **ray-casting technique**, written in **C** and rendered with **MLX42**. -This rendering is possible duo to classic **raycasting algorithm**, where one ray is cast per screen column to calculate wall distance and draw it correctly. +Each vertical stripe of the screen is rendered by casting a ray from the player’s +point of view, detecting wall intersections, computing distances, and projecting +textured walls with correct perspective. +Floor and ceiling colors are also rendered to complete the scene. + +This project focuses on: +- Low-level graphics programming +- Mathematical projection +- Parsing and validation +- Real-time rendering performance + + +### Features + +- Ray-casting rendering engine +- Directional wall textures (North, South, East, West) +- Floor and ceiling RGB colors +- Player movement and camera rotation +- Collision detection +- Strict `.cub` file parsing and validation +- Clean error handling and memory management +- MLX42 rendering loop --- @@ -20,27 +41,42 @@ This rendering is possible duo to classic **raycasting algorithm**, where one ra ### Requirements - Linux or macOS - - MLX / MLX42 - - 'gcc' or 'clang' + - CMake + - MLX42 / MLX + - C compiler (`gcc` or `clang`) ### Compilation +Clone the repository and run: ```bash make ``` +This will: +- Build MLX42 +- Compile `libft`, `ft_printf`, and `get_next_line` +- Generate the `cub3d` executable + ### Execution ```bash -./cub3D assets/maps/example.cub +./cub3D assets/maps/map.cub ``` +The program requires **exactly one argument**: a valid `.cub` map file. + ### Controls -Use W, A, S and D to mover the player. -Use UP, DOWN, LEFT and RIGHT arrows to rotate camera. -Use ESC for exit the program. +| Key | Action | +|---|---| +| `W` | Move forward | +| `S` | Move backward | +| `A` | Strafe left | +| `D` | Strafe right | +| `←` | Rotate camera left | +| `→` | Rotate camera right | +| `ESC` | Exit the program | -### Map configuration (.cub) +### Map configuration (`.cub`) A **.cub** file contains: - Wall textures (NO, SO, WE, EA) @@ -49,15 +85,33 @@ A **.cub** file contains: - 1 for walls - 0 for empty space - N, S, E or W for the player start position +- Spaces are allowed and handled correctly The map is strictly validated: -- Exactly one player position -- Fully closed by walls +- Exactly **one** player position +- Map must be **fully closed by walls** - Only valid characters +- No empty lines inside the map - RGB values between 0 and 255 +Example: + +``` +111111 +100001 +1000N1 +111111 +``` + ## Resources - +### AI Usage + +AI tools were used only as assistance, specifically for: +- Understanding ray-casting concepts +- Improving documentation clarity +- Reviewing logic and edge cases + +All generated content was reviewed, understood, and manually implemented. +No AI-generated code was copied blindly into the project. -