Cub3D is a 42's School project where the main goal is to make a first-person 3D representation of a maze by using raycasting.
Made by:
120/125
Theoretically it should work on both Linux and MacOS, but... the keybindings and the mlx
seem to differ between these OS.
So for now it only supports Linux
systems.
All tools you might need to build this project:
make
build-essential
wget
xorg
libxext-dev
libbsd-dev
unzip
(Debian/Ubuntu)
sudo apt install make build-essential wget xorg libxext-dev libbsd-dev unzip
To build the program you have just to run:
make
cub3D
requires one argument which should be the file with texture configurations and the actual map.
there are a few sample maps in assets/maps
folder.
E.g.:
./cub3D assets/maps/small.cub
The map files follow these rules:
- The file must have
.cub
extension. - The first part of the file defines the configuration:
- Each element firsts information is the type identifier (composed by one or two character(s)) followed by all specific informations for each object:
- Nord texture:
NO <path_to_the_north_texture>
- East texture:
EA <path_to_the_east_texture>
- West texture:
WE <path_to_the_west_texture>
- South texture:
SO <path_to_the_south_texture>
- Floor color (range [0,255], each value separated by comma):
F <RED>,<GREEN>,<BLUE>
- Ceiling color (range [0,255], each value separated by comma):
C <RED>,<GREEN>,<BLUE>
- Nord texture:
- Each element firsts information is the type identifier (composed by one or two character(s)) followed by all specific informations for each object:
- The map must be composed of only 7 possible characters:
0
for an empty space,1
for a wall, whitespaceN
,S
,E
orW
for the player’s start position and spawning orientation. - The map must be closed/surrounded by walls.
These are the implemented keybindings:
w
: Move forwarda
: Move lefts
: Move backwardsd
: Move right
Up arrow
: Look upDown arrow
: Look downLeft arrow
: Look leftRight arrow
: Look right
ESC
: Quit the game
Space
: JumpPageUp
: Minimap zoom inPageDown
: Minimap zoom outLeft Shift
: SprintLeft Control
: Squat/CrouchLeft Alt
: Guard mode (yeah it's useless but it's beautiful)
The game itself is made entirely in C.
The graphics library used here is a 42's wrapper for Xlib
called mlx
.
Most crazy part is that the whole project (except for mlx
) is wrote by following norminette
's rules... :P