Raycasting game inspired by Wolfenstein 3D
42 graphical project. The code is written in accordance with The Norm (42 coding style).
Raycasting algorithm is done using this tutorial, but with some my improvements and optimizations.
Besides the raycasting algorithm itself, the project includes most of the parsing and an error handling manager for invalid input data.
enginefolder -- source files (utilsfolder contains some functions from my own C library.mapsfolder --.cubfiles with map examples.mlxfolder -- 42 graphical library.texturesfolder -- wall and sprite textures, taken from Wolfenstein 3D, copyright by ID Software.
Makefile
make-- compilescub3Dexecutable.make demo1-- compilescub3Dand launches the game withbarrels.cubmap.make demo2-- same tomake demo1, but withsubj.cubmap.clean-- deletes object files.fclean-- deletes object files,cub3D,cub3D.bmpand runscleanrule inmlxfolder.re-- runsfcleanand recompiles.
Start game using following syntax : ./cub3D file.cub [--save]
file.cub-- nesessary option, file that config map and other parameters, you can find examples inmapsfolder.--save-- save option that will launch non-interactive mode, makes screenshot of first rendered image, saves it in bmp format (cub3D.bmp) and quit.
You can choose from existing maps (maps folder) or create your own one (see below).
- R x y -- screen resolution, x > 0, y > 0. If defined resolution is greater that current screen resolution and there is no
--saveoption, it will be resized to fit the current screen. In--savemode resolution can be greater than current screen. - NO path_to_texture -- texture for north side of the wall.
- EA path_to_texture -- texture for east side of the wall.
- SO path_to_texture -- texture for south side of the wall.
- WE path_to_texture -- texture for west side of the wall.
- S path_to_texture -- texture for sprite.
- C R,G,B -- ceiling color in RGB format.
- F R,G,B -- floor color in RGB format.
These params can be set in any order in the file, but before the map; they can be separated by any number of empty lines; within a parameter there can be any number of spaces between the arguments.
For C and F params R,G,B argument also can be separated by spaces, e.g. 42 , 42 ,42 is a valid input.
- map
Map can consists from 4 possible characters -- space, 1 for wall, 0 for blank space, and 2 for sprite. Map also must contain init position of the player -- N (looks to the north), E (to the east), S (to the south), W (to the west). There must be no empty lines inside or below the map.
Use WASD for moving, left arrow to turn head to the left and right arrow to turn head to the right. Press red cross on the window or ESC to quit.
