-
How raycasting works
-
Rendering 3d environments
-
How to write optimised code
(1920x1080 @ 60fps on an i5 7500)
A screenshot of the player in a maze, inspired by the style of doom
The minimap, which shows the orienatation of the player, as well as the blocks around them. This was accomplished without using any sprites.
For this project, we had to build a raycaster in C, where the player is able to move and look around a 3D world. This is accomplished with the help of MLX42 to manage i/o and to convert PNGs to a 2D int array. Everything else is made from scratch, such as:
- Parsing a map file
- Handeling movement
- Rendering the game
- Rendering the minimap.
Our map consists of a grid of squares, which can be open '0', a wall '1' or nothing ' '. To protect the player from staring into nothingness, all open tiles should be surrounded by either more open tiles or a wall. There should also be a player spawn, which is indicated by the direction the player is looking at. An example of a valid map, where the player starts of looking north:
11111
10001
10N01
11111
Above the map, you'll need to set the colour of the floor and ceiling with a custom RGB value. How to set a valid floor and ceiling colour:
C 255,0,0 // Red
F 100,100,100 // Gray
Finally, the textures of the walls should also be set (also above the map). This can be done by providing a relative path to every PNG file An example of how the textures should be set:
NO ./sprites/wall1.png
EA ./sprites/wall2.png
SO ./sprites/wall3.png
WE ./sprites/wall4.png
These are all the inputs our game uses:
WASD: Move the player
Shift: Sprint
Escape: Quit the game
Left/right arrow: Rotates camera
Tab: Toggles mouse on/off
Mouse: Rotates camera