Simple 3D raycasting project (school-style) that renders a first-person view from a 2D map using a DDA raycasting algorithm.
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(inlibs/libft) MLX42for rendering and window/input (inlibs/MLX42)
- custom
- Sample maps in
maps/and texture themes intextures/.
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.
- Linux (tested on Debian/Ubuntu)
- GCC (or clang)
- make (recommended)
- cmake (for MLX42 build)
- X11/OpenGL / system libs required by MLX42
libs/libftbuilt (runmakeinsidelibs/libft)libs/MLX42built (follow MLX42 build steps)
makeRun the compiled binary with a map file:
./cube3d maps/validmap00.cubIf no map is given (depends on implementation), run ./cube3d and follow the program messages.
- Maps are
.cubfiles in themaps/folder. Use the provided valid examples to test. - Invalid maps are included to help debug validation logic.
- 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.
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
- 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*andmaps/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/libftwas built andlibft.ais available. - Run the program from a graphical session (X11).
- "undefined reference" during link: verify
-Lpaths and thatlibs/libft/libft.aandlibs/MLX42/build/libmlx42.aexist. - "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.
- Try
./cube3d maps/validmap00.cuband./cube3d maps/testmap.cub. - Use
invalidmap*.cubto verify validation rejects malformed maps.
- 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.