A lightweight 3D engine built from scratch using raycasting, inspired by classic games like Wolfenstein 3D. This project uses the MiniLibX library to render a pseudo-3D world with walls, doors, and interactive elements. Designed with performance and modularity in mind.
-
🎮 First-person view maze rendering using raycasting.
-
🧱 Wall textures with directional support (North/South/East/West).
-
🌈 Configurable floor and ceiling colors.
-
📁 .cub map parser with a custom configuration format.
-
🕹️ Keyboard movement: W, A, S, D to move, ← → to rotate view.
-
❌ Clean exit with ESC key or window close.
-
💡 MiniLibX-based rendering.
-
🧪 Full memory safety (no leaks or crashes).
-
🎯 Advanced Interaction
-
🔫 Shooting system: right-click to fire.
-
🧠 Animated sprites.
-
🚪 Openable doors: textured, animated sliding doors.
-
🧱 Customizable wall/door placement logic that adapts to map input.
-
🧭 Minimap with camera tracking: shows player, walls, and objects in real-time with view direction.
-
🖱️ Mouse-based rotation: the mouse controls view direction smoothly.
-
🔒 Mouse lock: pointer stays centered in window for immersive control.
-
🎨 Multiple sprite and texture support through the .cub config file.
-
🧰 Map builder-friendly system: you can create your own maps with logic-controlled assets (textures, objects, etc).
-
💡 Raycasting engine: DDA algorithm for wall detection.
-
📦 Texture mapping: handles wall, sprite, and door textures with fine-grained offset logic.
-
🚶 Door animation engine: interpolates open/close with visual transition using fractional hit width.
-
🧭 Minimap rendering: scales dynamically and reflects player view direction in real time.
Each vertical screen slice casts a ray into the world:
- Determines wall hits and distance
- Calculates perpendicular projection to avoid fish-eye effect
- Determines door position and how much is visible based on animation progress
Doors animate using a progress value between 0.0 (closed) and 1.0 (fully open). When open:
- Collision is disabled when
progress >= 1.0 - A thin part of the door remains drawn for visual consistency
Mouse movement rotates the player's angle smoothly. The mouse is reset to the screen center after every frame to simulate continuous rotation.
NO ./textures/wall_north.xpm
SO ./textures/wall_south.xpm
WE ./textures/wall_west.xpm
EA ./textures/wall_east.xpm
F 220,100,0
C 30,30,30
111111
1N0D01
101101
1D1001
111111
-
0 → empty space
-
1 → wall
-
D → door (must be surrounded by at least two walls either vertically or horizontally)
-
N/S/E/W → player start and orientation
- Linux
- MiniLibX (included or installed)
- GCC or Clang
git clone https://github.com/bg-otman/cub3D.git
cd cub3D
make bonus
./cub3D maps/your_map.cub🙌 Credits
Developed by @bg-otman and @Aymanesaj, as part of 42/1337 Network’s Cub3D project.