Welcome to Cub3D
Cub3D is a raycasting engine inspired by the legendary Wolfenstein 3D, developed as part of the 42 School curriculum. The project implements a 3D first-person perspective using mathematical raycasting techniques, rendering a 2D map as an immersive 3D environment.What is Cub3D?
Cub3D explores the mathematical foundations of raycasting to create a pseudo-3D environment on a 2D screen. The engine handles:- Real-time raycasting for wall rendering
- Texture mapping and sprite rendering
- Collision detection and player movement
- Audio integration with spatial sound
- Controller support (Xbox, PlayStation, etc.)
- AI algorithms for enemy behavior
- Interactive elements like doors, elevators, and collectibles
Featured Maps
The project includes two distinct experiences:42 Lisboa Campus
Explore a 3D recreation of the 42 Lisboa campus with interactive elements
Wolfenstein 3D Levels
Complete first-person shooter experience with enemies, weapons, and the first two floors from the original game
42 Lisboa
A faithful 3D representation of the 42 Lisboa campus that you can freely explore. This map showcases the engine’s capabilities for architectural visualization and navigation.Wolfenstein 3D
A complete first-person shooter featuring:- Multiple enemy types with AI behavior
- Arsenal of weapons (pistol, machine gun, knife)
- Health and ammo pickups
- Elevators for multi-floor navigation
- The first two floors from the original Wolfenstein 3D
- A secret bonus floor for adventurous players
Platform Support
Desktop
Linux & macOSNative performance with SDL2
Web Browser
WebAssemblyPlay directly in your browser via Emscripten
Desktop Version
The native desktop version runs on both Linux and macOS, utilizing SDL2 for graphics rendering and input handling. It provides optimal performance with full controller support.Web Version
Thanks to Emscripten and WebAssembly, Cub3D runs seamlessly in modern web browsers. The web version maintains feature parity with the desktop build, allowing anyone to experience the game without installation. Play it here: https://omelhorsite.pt/en/games/cub3dKey Features
Raycasting Engine
Mathematical raycasting for real-time 3D rendering from 2D maps
Texture Mapping
Wall textures with proper perspective correction
Sprite System
Billboard sprites with 8-directional animation support
Audio Integration
Spatial audio with miniaudio library, supporting MP3 and other formats
Entity System
NPCs, enemies, and interactive objects with state machines
Controller Support
Full support for Xbox, PlayStation, and other game controllers
Map Format
Custom .cub format with extensive configuration options
Cross-Platform
Runs on Linux, macOS, and web browsers via WASM
Technical Highlights
Raycasting Implementation
The core rendering technique uses raycasting to simulate 3D perspective. For each column of pixels on screen, a ray is cast from the player’s position into the world, determining wall distances and heights to create the illusion of depth.Entity Animation System
Entities support 8-directional sprites with configurable animation frames, allowing for smooth character movement and combat animations from any viewing angle.Audio Engine
Integrated with the miniaudio library, Cub3D supports:- Positional 3D audio
- Multiple simultaneous sound instances
- Background music loops
- Dynamic sound effects based on gameplay events
Map Configuration
Maps are defined in.cub format, which includes:
- Wall texture assignments (NO, SO, EA, WE)
- Floor and ceiling colors
- Entity definitions and placements
- Custom sprite configurations
- Interactive element properties (doors, elevators)
- Player spawn position and orientation
Get Started
Quick Start
Compile and run Cub3D in minutes
Creating Maps
Learn how to build custom maps and configure entities
Credits
Developed by:- Afonso Coutinho (afpachec)
- Paulo Cordeiro (pvcordeiro)