The aim of this project is to create a simpler clone of the 90' famous first person shooter Wolfenstein.
Cub3d was a project developed by my team-partner Itopchu ( <--- many thanks for the cooperation!) and me.
The underlying goal of this project is to create and use a ray-casting algorithm able to render a sandobox environment where the player can move inside of it, even though it won't be able to shoot at spawning NPCs.
First, because an evironment is rendered a configuration file needs to be parsed, to gather informations regarding:
- graphic: textures to apply on thes (4 are needed, for walls facing respectively North, South, East, West);
- graphic: colors (RGB) of the ceiling and the floor;
- map: a map is required to render the environment (see the subject for guidelines about how to draw a valid map).
N.B. for all rules regarding the format of the input file see the subject;
N.B. there's another check performed by the parser and not required by the subject, that is done by a flood fill algorithm that ensures that no inaccessible rooms are admitted, i.e. the player can reach every empty spot inside the map.
Once the parsing is done, it is finally possible to render an image on the screen, as said before, the ray casting algorithm (see that) is used: the view of the player is considered to be a range of rays projected from the position of the player on a straight line, because the map (and so the player) is surrounded by walls, the longer every ray travels before hitting a wall, the smaller that portion of wall (i.e. column of pixels) will be drawn.
Once the game is running the following keys are available:
- ESC -> closes the game
- W, A, S and D -> allow the player to move
- left arrow and right arrow -> move the view on the left or right respectively
- left key mouse and drag -> moves the view depending on the direction of the dragging
A set of textures is already provided to enjoy the game, but it is still possibile to use some custom ones, their path must be written inside the parsed/input file and they must have a .png extension.
The project relies on the following submodules:
make
creates the executable;make run
callsmake
and runs the executable with the default arguments;make clean
removes object files;make fclean
callsmake clean
and removes the executable;make re
callsmake fclean
and thenmake
;
To execute the project without using make run
is necessary to provide an argument that represent the path of the input/parsed file.
include/ <- header file
libft/ <- auxiliary submodule
MLX42/ <- auxiliary submodule
objects/ <- object files
sources/ <- source C files
app/ <- handling of the MLX42 API
check_map/ <- specific checks on the input map
init/ <- constructors
main/ <- main function
parser/ <- parsing of the input file to gather info
render/ <- low level rendering done with ray-casting
tools/ <- generic functions
- 42 project: cub3d
- By: Francesco Aru and Itopchu, francesco.aru25@gmail.com, intra42/slack nickname: @faru, Codam, Amsterdam