No description
  • C 98.2%
  • Makefile 1.8%
Find a file
TreezZ f89e35652c
Merge add_minimap to main
Merge pull request #5 from 42-Minishell-Spablob3-TreezZ-Project/add_minimap
2026-07-17 16:40:38 +01:00
includes Missing texture edge case fixed! No leaks and norm passed. 2026-07-14 18:48:10 +01:00
libft@b9773ae1bc adding libft submodule 2026-04-25 16:38:22 +01:00
maps Missing texture edge case fixed! No leaks and norm passed. 2026-07-14 18:48:10 +01:00
media Added image, README should be done. 2026-07-17 14:37:24 +01:00
minilibx-linux@a0ce07ba22 organized directories and fixed check file extension 2026-04-25 18:23:45 +01:00
src Missing texture edge case fixed! No leaks and norm passed. 2026-07-14 18:48:10 +01:00
textures Missing texture edge case fixed! No leaks and norm passed. 2026-07-14 18:48:10 +01:00
.gitmodules organized directories and fixed check file extension 2026-04-25 18:23:45 +01:00
Makefile side of the walls are darken to create more 3D effect 2026-06-03 09:32:03 +01:00
README.md Added image, README should be done. 2026-07-17 14:37:24 +01:00

This project has been created as part of the 42 curriculum by grui-ant and joapedro.

🧱 42-Cub3d 🔫

A simple, Wolfenstein-inspired maze explorer, written in C.

"How can I find my way out of this maze?"

ingame.png

Description

We have taken upon ourselves to replicate the greats of the golden era of PC gaming.
We've made somewhat of a Wolfenstein 3D clone, but simpler in features, and also written in C.

The main purpose of this project is to give us an insight into low-level graphics.
By making a raycaster from scratch, similar to the one used in Wolfenstein 3D, we got a pretty decent peek into software rendering.

Features:

  • Wolfenstein 3D-inspired graphics, with:
    • A full, proper collision system;
    • A minimap, which you can expand;
  • A custom raycaster implementation built from scratch;
  • Classic DOS Style controls;
  • Usage of the 42 provided minilibx Graphics Library;
  • Partial static linking with our own Libft C Library.

Instructions

Building and Running

You will need to compile this program yourself, as no binaries are provided.
This project was was made with Ubuntu 22.04 as the target platform, so this guide will assume you are on Ubuntu.
However, you should be able to install the equivalent packages and build on your distro of choice.

Prequisites:

Install the following dependencies:

  • sudo apt install clang gcc git libxext-dev libbsd-dev make xorg zlib1g-dev

Clone this repository using Git, cd into it, and pull all dependencies:

  • git clone https://github.com/42-Minishell-Spablob3-TreezZ-Project/Cub3d.git && cd Cub3d

Once that's done, run GNU Make to build the source code into a executable binary:

  • make

make will also download and compile the submodules required for compilation.
The make clean and make fclean flags are also available to clean up the files created during compilation, as well as the binary, from the repository.

Running the program:

You can start the program by running the following command:

  • ./cub3d <NAME OF MAP>

You can choose any of the maps provided in /maps.

Map details:

A map file needs to abide by the following guidelines:

  • Four textures, which are indicated by four paths:
    • NO
    • SO
    • WE
    • EA
      • All of these followed by the path to the texture, which must be in a .xpm format.
  • RGB colour values, for the Floor and the Ceiling, represented by an F and a C respectively;
  • A single player, represented by a N, S, E, or a W character (the direction the player will face when the game is loaded);
  • A navigatable arena, where 0 represents walkable sections, and 1 represents a wall;
    • This arena must be surrounded by 1's in order to be valid. In other words, the arena where the player spawns must be closed off;
  • The map file must have a .cub extension.

Here's an example of a very simple valid map:

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

F  150,200,150 
C  200,200,214

111111111
100000001
100000001
100000001
1000N0001
100000001
100000001
100000001
111111111

With this in mind, you can create your own maps, as long as you follow said guidelines.

Gameplay

You'll be relegated to using classic DOS-style controls. Which means:

  • W, A, S, D for moving around;
  • Left and Right arrow keys for looking around
full.png

Don't forget you've got a minimap! You can zoom it up by pressing the M key.
And that's the gameplay for now. We might add a few things in the future. Or maybe not.

Resources

Miscellaneous

Enjoy a screenshot of this project in its early stages:

early.png