Skip to content
/ cub3d Public

3D game created from scratch similar to Wolfenstein 3D, where I explored the world of raycasting, using C and the minilibx library.

License

Notifications You must be signed in to change notification settings

jotavare/cub3d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Linkedin 42

AboutHow to useMandatoryBonusTeamNorminetteLicense

ABOUT

This is a graphics programming project where I created a 3D game in C, using the minilibx library. I learned about raycasting, basic algorithms, rendering 3D environments, textures, windows, colours, events, shape filling, wall collision, map parsing, mini-map, ...

This project is inspired by the world-famous Wolfenstein 3D game, by the famous John Carmack and John Romero (Id Software), and published in 1992 by Apogee Software, Wolfenstein 3D is the first true “First Person Shooter” in the history of video games.

A replica of the original game is available to play online here.

HOW TO USE

1º - Clone the repository

git clone git@github.com:jotavare/cub3d.git

2º - Enter the project folder and run make mlx

Note

This rule is not mandatory but necessary to run the game because the minilibx library is not included.

cd cub3d/cub3d
make mlx

3º - Run the game with a map of your choice

make re
./cub3d [map.cub]

MAKEFILE RULES

Rules Information
make Compile so_long files.
make all Compile mandatory files.
make clean Delete all .o (object files) files.
make fclean Delete all .o (object files) and .a (executable) files.
make re Use rules fclean + all.
make norm Uses the norminette on the libft and cub3d source files.
make mlx Downloads and compiles the minilibx library.

MANDATORY

MAIN RULES

  • Must use MiniLibX library;
  • The game window must remain smooth: changing to another window, minimizing, etc;
  • Display different wall textures that vary depending on which side the wall is facing (North, South, East, West);
  • Must be able to set the floor and ceiling colours to two different ones;

WINDOWS AND KEYS

  • Displays the image in a window;
  • Left and right arrow keys must allow you to look left and right in the maze.
  • The W, A, S, and D keys must allow you to move the point of view through the maze.
  • Pressing ESC or clicking on the cross on the window’s frame must close the window and quit the program cleanly.

MAP PARSING/VALIDATION

Note

The program must be able to parse any kind of map, as long it respects the rules:

  • The program has to take as a parameter a map description file ending with the .cub extension.
  • The map must be closed/surrounded by walls, if not, the program must return an error.
  • Map content always has to be the last.
  • Separated by one or more empty line(s).
  • Each type of element can be set in any order in the file.
  • Each type of information from an element can be separated by one or more space(s).
  • If an error/misconfiguration is encountered, it should return Error\n followed by an explicit message.

.cub COMPONENTS

  • The map must be composed of only 6 possible characters.
  • Each element's first information is the type identifier, followed by all specific information for each object;
Characters Description
0 Empty space.
1 Wall.
N S E W Player start position and orientation.
Name Example Identifier Information
North texture: NO ./path_to_the_north_texture NO Path to the north texure.
South texture: SO ./path_to_the_south_texture SO Path to the south texure.
West texture: WE ./path_to_the_west_texture WE Path to the west texure.
East texture: EA ./path_to_the_east_texture EA Path to the east texure.
Floor colour: F 220,100,0 F R,G,B colours in range [0,255]: 0, 255, 255
Ceiling colour: C 225,30,0 C R,G,B colours in range [0,255]: 0, 255, 255

Example of a valid .cub map:

NO ./path_to_the_north_texture
SO ./path_to_the_south_texture
WE ./path_to_the_west_texture
EA ./path_to_the_east_texture

F 220,100,0
C 225,30,0

        1111111111111111111111111
        1000000000110000000000001
        1011000001110000000000001
        1001000000000000000000001
111111111011000001110000000000001
100000000011000001110111111111111
11110111111111011100000010001
11110111111111011101010010001
11000000110101011100000010001
10000000000000001100000010001
10000000000000001101010010001
11000001110101011111011110N0111
11110111 1110101 101111010001
11111111 1111111 111111111111

BONUS

  • Wall collisions.
  • A minimap system.
  • Doors which can open and close.
  • Animated Sprite.
  • Rotate the point of view with the mouse.

TEAM

GitHub 42 Intra
Pedro Mota psotto-m
João Oliveira jotavare

NORMINETTE

At 42 School, it is expected that almost every project is written following the Norm, which is the coding standard of the school.

- No for, do...while, switch, case, goto, ternary operators, or variable-length arrays allowed;
- Each function must be a maximum of 25 lines, not counting the function's curly brackets;
- Each line must be at most 80 columns wide, with comments included;
- A function can take 4 named parameters maximum;
- No assigns and declarations in the same line (unless static);
- You can't declare more than 5 variables per function;
- ...
  • 42 Norms - Information about 42 code norms. PDF
  • Norminette - Tool to respect the code norm, made by 42. GitHub
  • 42 Header - 42 header for Vim. GitHub

LICENSE

This work is published under the terms of Unlicense.