Ray-casted maze runner with responsive controls, immersive textures, and a self-diagnosing tester suite.
Project still in development — built by alteixeira20 and jopedro-.
Live preview of the current gameplay loop.
- At a Glance
- About
- Subject Compliance
- Custom Tester
- Repository Layout
- Build & Integration
- Usage Guidelines
- Feature Deep Dive
- Input & Animation
- Rendering & HUD
- Internal Architecture
- Tester Workflow
- Results & Reporting
Highlights: Completely autonomous raycaster with defensive parsing, evaluation-ready tooling, and intentionally smooth locomotion.
- Mandatory loop mirrors Wolfenstein 3D: textured walls, real-time pitch, keyboard-only input, graceful exit paths.
- Movement profiling pays off: simultaneous
W+A+S+Dstrafes stay responsive while the camera glides through a full 360° sweep without visible stutter. - Bonus build unlocks doors, collectibles, minimap overlays, HUD counters, and animated sprites without breaking subject rules.
- One
Makefiledrives everything: libft fetch/build, MiniLibX compilation, standard & bonus executables, and diagnostic testers. - Project ships with curated invalid/valid scenes, tester automation, and Git-friendly assets to accelerate peer reviews.
Highlights: Purpose-built for 42 Porto’s first-person graphics milestone.
- Implements a full raycasting pipeline in C using MiniLibX to render a 1920×1080 viewport at interactive speeds.
- Leverages a modular parser to read
.cubscene files, normalize spaces to walkable floor, and enforce all subject-required identifiers. - Bonus feature set focuses on readability: minimap zoom, door state interpolation, collectible animations, and HUD counters for keys.
- Co-developed with jopedro-; we review each feature together to keep the codebase approachable while we iterate.
Highlights: Every mandatory bullet of the subject PDF is covered and auditable.
.cubloader validates identifiers (NO/ SO/ WE/ EA/ F/ C), detects duplicate/missing entries, and guarantees readable.xpmtextures.- Map parser enforces rectangularity, sealed boundaries, unique player spawn, and safe dimensions (
8192×8192max) before gameplay begins. - Game loop respects official controls (
WASD, arrow keys,ESC, window close), updates steering smoothly, and frees all resources on exit. - Floor/ceiling colors are clamped per RGB component; invalid numeric ranges or trailing characters halt the run with explicit errors.
Highlights: Built-in automation keeps evaluations consistent and transparent.
Custom tester showcasing automated invalid-map and texture sweeps.
make testerchainstest_invalidandtest_texturesto scrutinize failure handling and leak hygiene with Valgrind.- Tester iterates curated invalid scenes, checks for the mandatory
Errorheader plus a descriptive second line, and reports pass/fail tallies. - Texture tests temporarily remove read permissions from every
.xpm(map walls + collectibles) to ensure the engine surfaces the offending filename. - Automation skips noise: it cleans temp files, restores permissions, and only prints actionable verdicts for quick debugging.
Highlights: Clear separation between engine, bonus mechanics, and tooling.
src/— Mandatory build: init, parser, validation, rendering, input loop, and cleanup helpers.src_bonus/— Bonus-exclusive systems (doors, minimap, collectibles, HUD, mouse input) mirroring the mandatory structure.inc/— Shared headerscub3d.h&cub3d_bonus.hwith macros, error messages, structs, and prototypes.mlx/&libft/— Vendor code fetched/compiled automatically by the Makefile.maps/valid&maps/invalid— Reference scenes, including oversize stress tests (invalid_map_width.cub,invalid_map_height.cub).docs/— Official subject PDF plus trimmed gameplay videos;images/contains autoplay-ready GIFs for documentation.
Highlights: Single Makefile handles dependencies, binaries, and diagnostics.
# Build mandatory target
make
# Build bonus target (doors, minimap, collectibles)
make bonus
# Launch the tester suite
make tester
# Launch Test of Invalid Map Formats
make test_invalid
# Launch Test of Invalid/Missing Texture
make test_textures
# Clean / rebuild helpers
make clean # remove objects
make fclean # clean + binaries + libft clone
make re # rebuild from scratchmakeclones libft on demand, compiles MiniLibX silently, and links the mandatory executable at./cub3D.make bonusreuses the same dependency flow for./cub3D_bonuswith the extended feature set.- Valgrind presets (
make valgrind,make valgrind_bonus,make valgrind_invalid) provide leak and UB checks without extra setup.
Highlights: Ship-ready binaries with preset maps and keyboard-centric controls.
- Run the game by pointing to any
.cubscene:./cub3D maps/valid/map1.cub ./cub3D_bonus maps/valid/map_with_keys.cub
- Use
make mapsfor an interactive launcher that lets you choose executable (mandatory/bonus) and browse valid or invalid maps. - Keyboard layout:
W/Smove forward/backward,A/Dstrafe, arrow keys rotate view.ESCor the window close button terminate cleanly.- Bonus build adds
Mto toggle pause/mouse capture, door proximity triggers, and collectible pick-ups.
Highlights: Every subsystem is auditable through optional deep dives.
Parsing & Validation
parse_allstreams the.cubfile, trims carriage returns, and categorizes lines before touching map content.- Lines buffer collects map rows while preserving visual layout—spaces become floor (
'0'), padding remains' 'to guard boundaries. - Texture loader confirms
.xpmextension after trimming, rejects unreadable paths, and frees memory on failure. - Flood-fill seal check duplicates the grid and ensures the player spawn is completely enclosed before gameplay.
Raycasting & Collision
ray_setup,ray_dda, andray_compute_linesimplement classic DDA raycasting with perpendicular distance correction to avoid fish-eye distortion.- Door slices reuse ray state: when a ray hits an open door, a secondary search finds the backing wall to render correct parallax.
- Movement normalizes combined direction vectors, scales by
ms = 0.07(mandatory) orPLAYER_MOVE_SPEED(bonus), and checks four collision corners usingCOLL_R.
Bonus Gameplay Systems
- Doors fade via
DOOR_OPEN_SPEEDanddoor_plane_offset, whileupdate_doors_for_framesyncs animations per frame. - Collectibles employ preloaded sprite frames (
assets/key/) with bobbing and phase offsets to keep motion varied. - Minimap samples the world using a 2×2 anti-aliased approach, draws the player marker, and can be toggled/panned via configuration.
Highlights: Smooth keyboard steering with optional mouse look and pitch.
- Mandatory build manages
t_inputflags forWASD+ arrows; rotation helpers (rotate_left/right) rely on cosine/sine updates, even when combining strafes for diagonal movement. - Bonus input captures the X pointer delta for mouse yaw, clamps pitch (
±0.5) to prevent gimbal lock, and hides the cursor while active. - Camera yaw handles full 360° sweeps while walking, so panning and locomotion remain in sync and free of visible hitching.
- Animation loops include door interpolation, key sprite advancements (12 FPS) via
collectibles_update, and player pitch offsets in view calculations.
Highlights: Layered presentation keeps the frame clean and informative.
- Texture sampling uses
get_texelwith side-based shadowing to emphasize depth; floor/ceiling colors fill above/below the column gracefully. - Bonus rendering calls
draw_frameto stack door slices, collectibles, HUD text, minimap, and crosshair over the raycast background. - Minimap sampling stays locked to the player—even during mouse-only camera spins—so your marker, door arcs, and nearby walls reflect real-time movement without jitter.
- HUD labels render through custom bitmap fonts (
ui/hud/hud_text.c) and summarize collected keys versus total available.
Highlights: Predictable modules make debugging painless.
- Initialization (
src/init,src_bonus/init) zeroes textures, player state, render buffers, and input structs. - Cleanup routines (
clean_game,clean_keys,clean_doors) ensure every malloc’d buffer or MiniLibX image is freed on both normal and error exits. - Core structs (
t_game,t_render,t_ray,t_collectibles) centralize runtime state; helpers access them via clear, single-responsibility functions. - Build system isolates object folders (
obj,obj_bonus) to keep mandatory and bonus artifacts from colliding.
Highlights: Automation doubles as documentation and safety net.
test_invalidloops throughmaps/invalid, asserts the two-line error contract, and runs Valgrind with--error-exitcode=42to catch leaks.test_texturestoggles file permissions per texture, reruns the chosen executable, and checks that the offending filename is cited in the error text.- Both testers maintain pass/fail counters, skip missing assets, and exit non-zero if any case fails—perfect for CI hooks or peer review scripts.
- The
running_tester.gifprovides an at-a-glance view for evaluators on how verdicts appear in real time.
Highlights: Output stays focused on decision-grade information.
- Gameplay sessions log only critical events: parsing success, runtime errors, and cleanup confirmations—no noisy debug spam.
- Tester logs print succinct per-map verdicts plus a final summary line (e.g.,
Passed 23 tests and 0 tests.) so issues are immediately visible. - Valgrind integrations suppress known MiniLibX noise (
valgrind.supp) and bubble up leaks or invalid reads with actionable diffs.