derfleck / cub3d

First steps with raycasting using the minilibx library, project for 42 Vienna

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cub3d

Passed Cub3D with 115

Passed with 115/100

Screenshot from the game

cub3d is a project that challenges you to recreate game history. Your goal is to build a simple pseudo-3D-game using an approach called ray casting. This has been pioneered in 1993 by id Software with the title Wolfenstein 3D (depending on your age you might know its successors Return to Castle Wolfenstein, Wolfenstein: New Order or even its predecessor Castle Wolfenstein).

Ray casting allows you to render 2D images of simple 3D scenes. For the full explanation, have a look at the linked tutorials in the resources section.

The project requires you to use the minilibx library by 42 Paris. There's an improved (and better documented) version by Codam (42 Amsterdam) called MLX42, but if it's allowed to use is up to your local Bocal (ask them if you're not sure). There's only a limited set of functions permitted in general:

  • all functions of miniLibX and math library

  • system functions for files: open, close, read, write

  • functions for printing output (mainly used for error handling): printf, perror, strerror

  • functions for memory management and process termination: malloc, free and exit

Resources

Lode's tutorial on Raycasting: probably the best tutorial on raycasting out there, with code examples step by step (links provided as list here, part 4 is linked on the main page, but somehow not on part 3)

Could also be useful for some, if you haven't worked with it on so_long: Lode's tutorial on floodfill. Many colleagues from other campuses recommended the Permadi tutorial on Raycasting, but it uses only the angle instead of vectors for the looking direction, which I found harder to use.

I highly recommend the Game Engine Black Book: Wolfenstein 3D, 2nd Edition by Fabien Sanglard, which documents the whole development process of Wolfenstein 3D from a technical perspective. Additionally, if you're into game history, read DOOM Guy: Life in First Person by John Romero, written by one of the founders of id Software.

Coding Train has a helpful explanation how raycasting works, but his code examples are in JS. The video series by 3DSage is closer to the subject of cub3d because it uses C and OpenGL. There's also a course by Pikuma which has been highly recommended, but it's 60 USD for enrolling.

MLX specific resources

Testers

  • Cub3D Leaks Maps Tester: outdated, but contains some test maps that can be repurposed (but remove the resolution line at the top)

About

First steps with raycasting using the minilibx library, project for 42 Vienna


Languages

Language:C 97.3%Language:Makefile 2.7%