cub3D - My First RayCaster with miniLibX
cub3D is a 3D maze exploration game created as part of my project to explore Ray-Casting techniques and graphics programming. Inspired by the iconic Wolfenstein 3D, this project allows users to navigate through a maze with a first-person perspective. The program is built using C and the miniLibX graphics library.
🚀 Features
Ray-Casting Engine: A 3D perspective is generated from a 2D maze map using ray-casting techniques.
First-Person Movement: Use W, A, S, D to move and the arrow keys to look around.
Texture Mapping: Different textures are applied to walls based on the cardinal directions (North, South, East, West).
Floor and Ceiling Colors: Configurable colors for the floor and ceiling in the game environment.
Smooth Window Management: Handles window events like minimizing, resizing, and closing gracefully.
Customizable Map: The game loads a map from a .cub file and checks for any misconfigurations.
Error Handling: Proper error messages and program exits in case of invalid map configurations or other errors.
🛠️ Installation
To get started with cub3D, follow these steps:
Clone the repository:
git clone https://github.com/oelbouha/cub3d.git
cd cub3D
Install dependencies:
You will need the miniLibX graphics library. On macOS, it is typically available via brew. On Linux, you can install it through your package manager or build it from source.
Compile the program:
Ensure you have Makefile configured to build the project:
make
Run the program:
After compilation, you can run the game by providing a .cub map file as an argument:
./cub3D path_to_map.cub
📝 Map Format
The game requires a .cub file that defines the textures, colors, and the maze layout. A simple example of a .cub file is as follows:
NO ./textures/north_texture.xpm
SO ./textures/south_texture.xpm
WE ./textures/west_texture.xpm
EA ./textures/east_texture.xpm
F 220,100,0
C 225,30,0
111111111111111
100000000000001
101100000000001
100100000000001
111111111111111
Textures: Path to the .xpm texture files for North, South, East, and West.
Colors: RGB values for the floor (F) and ceiling (C) colors.
Map: A grid of 1s (walls) and 0s (empty spaces), with N, S, E, or W representing the starting position and orientation.
⚙️ Controls
W: Move forward
A: Move left
S: Move backward
D: Move right
Arrow keys: Look left, right, up, or down
ESC: Exit the game
Red cross (top-right corner): Close the game window
💻 Technologies Used
C Programming Language
miniLibX for graphics rendering
Makefile for project build and compilation
Math Functions for ray-casting calculations
🐛 Troubleshooting
Invalid Map Format: If your map is not in the correct format or has errors, the program will display an error message and exit gracefully.
Missing Textures: Ensure your .cub file points to the correct paths for texture images.
