Skip to content

ckhater/CUB3D

Repository files navigation

CUB3D

A 3D maze exploration game built in C using ray casting and the MinilibX graphics library.

Table of Contents

Prerequisites

  • Compiler: GCC or Clang
  • Build Tool: Make
  • Libraries: X11 development libraries

Required Libraries: The following development packages must be installed:

  • libx11-dev - X11 client library development files
  • libxext-dev - X11 miscellaneous extension library development files

Install Dependencies:

sudo apt-get update
sudo apt-get install -y libx11-dev libxext-dev

On other Linux distributions:

  • Fedora/RHEL: sudo dnf install libX11-devel libXext-devel
  • Arch: sudo pacman -S libx11 libxext

Running the Game

Main Version

./cub3D maps/map_m.cub

Bonus Version

./cub3D_bonus maps/map_b.cub

Game Controls

  • W - Move forward
  • A - Strafe left
  • S - Move backward
  • D - Strafe right
  • Left Arrow - Rotate camera left
  • Right Arrow - Rotate camera right
  • Up Arrow - Move forward
  • Down Arrow - Move backward
  • Mouse - Look around (bonus version)
  • x - Wave the weapon (bonus version)
  • g - Call granny (bonus version) "it works only after the player moved from its initial position"
  • SPACE - open the door (bonus version)
  • ESC - Exit game

Project Structure

.
├── cube.h / cube_bonus.h    - Header files
├── main.c / bonus/main_bonus.c - Entry points
├── minilibx-linux/          - Graphics library
├── maps/                    - Game maps
├── textures/                - Game textures
└── [various .c files]       - Source code modules

Cleaning Up

# Remove object files
make clean

# Remove object files for bonus
make clean_bonus

# Full cleanup 
make fclean
# Full cleanup for bonus
make fclean_bonus

Troubleshooting

Error: "mlx.h: No such file or directory"

  • Make sure you've compiled MinilibX: cd minilibx-linux && make && cd ..
  • Update your Makefile with -I./minilibx-linux flag

Error: "Can't find a suitable X11 include directory"

  • Install X11 development libraries:
    sudo apt-get install libx11-dev libxext-dev

Error: Can't connect to X11 display

  • This is normal on headless systems without X11 display server
  • Try using Xvfb if you need to run on a headless server:
    sudo apt-get install xvfb
    xvfb-run ./cub3D maps/map_m.cub

Contributors

This project was developed by:

Created as part of the 42 School curriculum.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages