Skip to content

itsiros/Cube3D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cube3D

Simple 3D raycasting project (school-style) that renders a first-person view from a 2D map using a DDA raycasting algorithm.

Overview

This project implements a basic Wolfenstein-like raycasting engine in C. Main responsibilities implemented:

  • Map parsing and validation (.cub files in maps/).
  • Raycasting (DDA algorithm) and textured wall drawing (src/raycasting/).
  • Player movement and input handling (src/hooks.c, src/player.c).
  • Basic file utilities and small GC-like wrappers used across the codebase.
  • Uses external libraries:
    • custom libft (in libs/libft)
    • MLX42 for rendering and window/input (in libs/MLX42)
  • Sample maps in maps/ and texture themes in textures/.

Project layout

  • src/ — main C sources:
    • main.c, init.c, render.c, map_utils.c, validation.c, etc.
    • raycasting/ — raycasting implementation (dda algorithm, drawing, ray calculations).
  • includes/ — headers (cube3d.h, raycasting.h).
  • libs/
    • libft/ — project libft (must be built).
    • MLX42/ — graphics/input library (must be built).
  • maps/ — map files (.cub). Examples: validmap00.cub, invalidmap01.cub, testmap.cub.
  • textures/ — texture folders (themes: desert/, space/, ...).
  • README.md — this file.

Requirements

  • Linux (tested on Debian/Ubuntu)
  • GCC (or clang)
  • make (recommended)
  • cmake (for MLX42 build)
  • X11/OpenGL / system libs required by MLX42
  • libs/libft built (run make inside libs/libft)
  • libs/MLX42 built (follow MLX42 build steps)

Setup & Build

make

Run / Usage

Run the compiled binary with a map file:

./cube3d maps/validmap00.cub

If no map is given (depends on implementation), run ./cube3d and follow the program messages.

Maps

  • Maps are .cub files in the maps/ folder. Use the provided valid examples to test.
  • Invalid maps are included to help debug validation logic.

Textures

  • Texture themes live in textures/<theme>/. The engine will use textures referenced by the map parser / configuration (see the map format your parser expects).
  • To add a theme, create a folder under textures/ and place the texture image files used by the map.

Controls

Typical controls implemented (common for raycasters). If your implementation differs, consult src/hooks.c:

  • W — move forward
  • S — move backward
  • A — strafe left
  • D — strafe right
  • Left / Right arrows — rotate view
  • ESC — quit

Validation & Debugging

  • Map validation is performed at load time (see src/validation.c). If map is invalid, the program will print an error and exit.
  • Use the maps/test* and maps/invalid* files to see validation behavior.
  • If you get rendering / MLX errors:
    • Confirm MLX42 is built and the library path is correct.
    • Make sure libs/libft was built and libft.a is available.
    • Run the program from a graphical session (X11).

Common troubleshooting

  • "undefined reference" during link: verify -L paths and that libs/libft/libft.a and libs/MLX42/build/libmlx42.a exist.
  • "Cannot open display": ensure you run inside an X session (not plain SSH without X forwarding).
  • Unexpected behavior after code changes: recompile MLX42 and libft if you altered those libs, and re-run make.

Tests & Examples

  • Try ./cube3d maps/validmap00.cub and ./cube3d maps/testmap.cub.
  • Use invalidmap*.cub to verify validation rejects malformed maps.

Notes & Next steps

  • The code contains a simple resource/GC wrapper; ensure any allocated memory is freed on exit.
  • To add features: sprites, floor/ceiling textures, minimap, improved collision physics.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors