Cub3d is a project at 42 school designed to introduce students to the basics of raycasting. The goal is to create a simple 3D game engine using 2D raycasting to render a maze-like world from a first-person perspective. This project aims to enhance your understanding of graphics programming and game development fundamentals.
- 2D raycasting engine to render a 3D perspective.
- Player movement and rotation.
- Textured walls.
- Simple sprite rendering.
- Basic keyboard controls for movement and interaction.
- C programming language
- MinilibX (a simple X-Window programming API)
- Make
-
Clone the repository:
git clone https://github.com/Tyranno-Rex/cub3d
-
Navigate to the project directory:
cd cub3d
-
Compile the project:
make
-
Run the executable:
./cub3d [path_to_map_file.cub]
-
Controls:
W
: Move forwardS
: Move backwardA
: Strafe leftD
: Strafe rightLeft Arrow
: Rotate leftRight Arrow
: Rotate rightESC
: Exit the game
The map file (.cub
file) should define the layout of the game world. Below is an example of a simple map file format:
R 640 480 // Resolution: width and height
NO ./textures/north.xpm // Path to the texture for the north wall
SO ./textures/south.xpm // Path to the texture for the south wall
WE ./textures/west.xpm // Path to the texture for the west wall
EA ./textures/east.xpm // Path to the texture for the east wall
S ./textures/sprite.xpm // Path to the sprite texture
F 220,100,0 // Floor color (R,G,B)
C 225,30,0 // Ceiling color (R,G,B)
111111
100001
102001
100001
111111
1
: Wall0
: Empty space2
: Sprite
cub3d.h libft.h struct.h
cub3d/
├── includes/
│ ├── cub3d.h // Header file for project-wide definitions
│ ├── libft.h // Header file for the Libft library
│ ├── struct.h // Header file for project structures
├── libft/ // Libft library source files
├── maps/ // Directory for map files
├── mlx/ // MinilibX library files
├── src/
| ├── mlx/ // MinilibX source files
│ ├── exit_game.c // Functions for closing the window
│ ├── init_game.c // Functions for initializing the game
│ ├── key_hook.c // Functions for handling keyboard input
│ ├── mlx_utils.c // Utility functions for MinilibX
│ ├── move_player.c // Functions for player movement
│ ├── raycast.c // Functions for raycasting
│ ├── render.c // Functions for rendering the game
│ ├── parsing/ // Source files for parsing the map file
│ ├── check_map.c // Functions for validating the map
│ ├── color.c // Functions for parsing colors
│ ├── map.c // Functions for handling the map
│ ├── map_utils.c // Utility functions for the map
│ ├── parsing.c // Functions for parsing the map file
│ ├── parsing_utils.c // Utility functions for parsing
│ ├── utils.c // Utility functions for the project
│ ├── utils2.c // More utility functions
│ ├── main.c // Entry point of the program
├── textures/ // Directory for texture files
├── Makefile // Build script
└── README.md // Project documentation
This project is licensed under the MIT License. See the LICENSE file for more details.
PROJECT_NAME : cub3d_t PROJECT_DESCRIPTION : Cub3d is a project at 42 school designed to introduce students to the basics of raycasting. The goal is to create a simple 3D game engine using 2D raycasting to render a maze-like world from a first-person perspective. This project aims to enhance your understanding of graphics programming and game development fundamentals. PROJECT_URL : 'https://github.com/Tyranno-Rex/cub3d.git' PROJECT_COMPLETION_STATUS : TRUE PROJECT_MULTI : FALSE PROJECT_SUBPROJECT : NONE PROJECT_CATEGORY : 'graphic', 'game&simulation', 'algorithm', 'teamTask'