This project is inspired by the world-famous Wolfenstein 3D game, which was the first FPS ever. It is a raycasting game, which means that it uses raycasting techniques to render a 3D environment in a 2D map.
The goal of this project is to create a dynamic view inside a maze, in which you can move around and interact with objects.
To install the game, you need to run the following commands:
Note: This project was developed on macOS, so it may not work on other operating systems, also it requires the minilibx
library to run.
git clone https://github.com/bablilayoub/cub3D
cd cub3D
make all bonus clean
To run the game, you need to run the following command:
./cub3D maps/map.cub
./cub3D_bonus maps/map_bonus.cub
W
A
S
D
to move around←
→
to rotate the cameraESC
to exit the gameSPACE
to open/close the doors
The map is configured in a .cub
file, which is a text file that contains all the information needed to render the game.
Here is an example of a map configuration:
NO ./textures/wall_n.xpm
SO ./textures/wall_s.xpm
WE ./textures/wall_w.xpm
EA ./textures/wall_e.xpm
F 220,100,0
C 0,100,220
1111111111111111111111111
1000000000110000000000001
101100000111000000W000001
1001000000000000000000001
1111111110110000011100001
1000000000110000011100001
1011100000000000000000001
1000100000110000000000001
1000100000110000000000001
1000111101111100000000001
1000000000000000000000001
1111111111111111111111111
NO
,SO
,WE
,EA
are the paths to the textures of the wallsF
is the color of the floorC
is the color of the ceiling- The map is composed of numbers and letters:
1
is a wallSPACE / TABS
are empty spaces0
is an empty space (floor)N
,S
,W
,E
are the player's starting position and orientationD
is a door
- Wall collisions
- Sprite
- Minimap
- Doors
- Mouse rotation
This project was a great opportunity to learn more about raycasting techniques and game development. It was a challenging project, but it was also very rewarding to see the final result.
I hope you enjoy playing this game as much as I enjoyed creating it!