2024-08-14
It has been a while but I am back. I haven't been posting much but I was super focussed on the 42 projects and one of them is cub3d. The last project that uses the minilibx library and also the last big project of the common core in C. In this project we needed to make a wolvenstein 3d like raycaster. It was a group project and I took it onto myself to make the raycaster and do all the math. This seemed okay at the beginning but I ended up rewriting the raycaster 3 times. First I used to calculate everything with angles that the player if viewing but this gave me some fisheye effects and after some digging I got it fixed for the full horizontal walls but still under angles the walls weren't straight so I needed to find something else. Then I found the raycaster documentation from Lode (https://lodev.org/cgtutor/raycasting.html) and I followed this and it worked absolutely perfect. The use of a camera plane is just genius and definetly go check out his documentation about it.
But we didn't finish there. We wanted to do cub3d with the bonusses so we then started to add doors that you can open and also a minimap. Animated sprites where the last one we needed to implement and this gave us a lot of struggles because MLX and threads don't go well togheter and also the computers didn't like what we were doing. At the end we got it implemented and it all worked great. There are still some minor issues with it but this is definetly a project I will come back to and try to make better with openGL and C++.