Welcome to our Cub3d project! Dagmar Kramer and myself worked together as a team to create a simple 3D game using raycasting techniques. Our game is inspired by the classic Wolfenstein 3D, and we've added some fun features to make it our own. In this project, we've used the C programming language and the miniLibX graphics library to build the game from scratch. We're excited to share our project with you. Please feel free to explore the code and leave us any feedback you have.
The Cub3d game utilizes raycasting techniques to create a 3D effect in a 2D environment. Raycasting involves simulating the behavior of light rays to render a 3D scene from a 2D map. To achieve this, several mathematical calculations are involved. Here's a brief overview of the math used in our raycaster:
-
Trigonometry: Trigonometric functions such as sine and cosine are essential for determining the angles at which rays are cast. These angles are used to calculate the ray direction and perform various calculations during raycasting.
-
Line Intersection: The raycaster traces rays from the player's position to the walls of the game world. To determine where a ray intersects with a wall, we use line intersection formulas. These formulas involve vector operations and algebraic equations.
-
Distance Calculation: To render the walls correctly, we need to calculate the distance between the player and the wall intersection point. This calculation is based on the Pythagorean theorem or other distance formulas.
-
Texture Mapping: In order to apply textures to the walls, we map the 2D textures onto the 3D walls based on the intersection points. This process involves converting the 3D coordinates to texture coordinates using mathematical transformations.
During the development of Cub3d, we extensively applied these mathematical concepts to achieve accurate rendering, depth perception, and movement within the game.
To compile the Cub3d game, follow these steps:
- Run
make
command in the project directory.
To run the Cub3d game, follow these steps:
- Execute the command
./cub3D maps/codam.cub
in the project directory. You can also use another map file instead ofmaps/codam.cub
. - Use the WASD keys and arrow keys to move and look around in the game.