A 3D game engine built from scratch using ray-casting magic!
Welcome to my Cub3D project! This is a journey through the fascinating world of ray-casting - the same technique that powered legendary games like Wolfenstein 3D. I've built this engine step by step, and I'm excited to share the results with you.
I've DONE all the ray-casting and developed a comprehensive visual guide that demonstrates the fundamental principles of ray-casting algorithms. This interactive educational tool provides step-by-step breakdowns of the mathematical concepts and implementation strategies.
Created by Me: (@ma1loc) => ๐ Access Ray-Casting Tutorial

Ray-casting is a brilliant technique that creates the illusion of 3D environments from 2D maps. Imagine casting invisible rays from your eyes in all directions - wherever they hit a wall, that's what you see! It's like having mathematical superpowers that turn flat maps into immersive 3D worlds.
I've approached this project in three exciting phases, each building upon the previous one. Here's how the magic unfolds:
This is where everything begins! I implemented the core ray-casting algorithm and visualized it in 2D so you can actually see the rays being cast from the player's position.
The_2D_Ray-casting.mp4
What you'll see:
- Rays shooting out from the player position
- Real-time intersection detection with walls
- The mathematical foundation that makes everything possible
Here's where things get really exciting! I transformed those 2D calculations into a proper 3D environment. You can walk around and experience the world in three dimensions.
The_3D_Projection.mp4
What you'll see:
- Full 3D environment with proper perspective
- Smooth player movement and rotation
- Walls that get taller or shorter based on distance
The grand finale! I added beautiful textures to bring the world to life. This is where the engine truly shines and feels like a real game.
The_3D_Ray-casting_with.textures.mp4
What you'll see:
- Gorgeous textured walls
- A fully immersive 3D environment
- The complete ray-casting experience
The heart of the engine uses the DDA (Digital Differential Analyzer) algorithm to efficiently detect where rays hit walls. It's like having a super-fast mathematical detective that finds intersections in milliseconds!
- Fisheye Correction: No weird distortions - everything looks natural
- Perspective Perfection: Walls scale correctly based on distance
- Smooth Performance: Optimized for real-time rendering
- Texture Mapping: Beautiful textures mapped precisely to wall surfaces
- Trigonometry: For calculating ray directions and angles
- Linear Algebra: Vector math for 3D transformations
- Coordinate Geometry: Converting between different coordinate systems
- Optimization Techniques: Making everything run smoothly
Controls:
- W/A/S/D: Move around the world
- โ/โ Arrow Keys: Look left and right
- ESC: Exit when you're done exploring
Installation:
# Clone and enter the project
git clone https://github.com/ma1loc/Raycasting3D_game.git
cd Raycasting3D_game
# Build the engine
make
# Launch with a map
./cub3d maps/main_map.cub
- Built from scratch - Every line of code crafted with care
- Mathematical precision - Accurate calculations for perfect visuals
- Performance optimized - Smooth gameplay experience
- Clean architecture - Well-organized, maintainable code
This project taught me so much about:
- Computer Graphics Fundamentals - How 3D graphics really work
- Algorithm Implementation - Turning theory into working code
- Performance Optimization - Making real-time graphics smooth
- Problem Solving - Overcoming complex technical challenges
The skills demonstrated here are directly applicable to:
- Game Engine Development ๐ฎ
- 3D Visualization Software ๐
- Simulation Systems ๐ฌ
- Graphics Programming ๐จ
I'm always thinking about how to make this even better:
- Sprites and Objects: Adding 3D enemies and items
- Floor and Ceiling Textures: Complete environment texturing
- Dynamic Lighting: Shadows and atmospheric lighting
- Sound System: Immersive 3D audio
- Multiple Levels: Different maps and environments
Ray-casting fascinated me because it's where mathematics meets visual artistry. There's something magical about transforming abstract mathematical concepts into immersive visual experiences. This project represents hundreds of hours of learning, coding, debugging, and refining - and I loved every minute of it!
It's not just about the final result; it's about understanding how the graphics in our favorite games actually work under the hood. When you see those textured walls in the final demo, you're witnessing pure mathematics transformed into visual reality.
I'm passionate about graphics programming and always excited to discuss technical challenges, share knowledge, or collaborate on interesting projects. Feel free to explore the code, ask questions, or share your thoughts!
"Ray-casting: Where mathematics becomes magic, and flat worlds become infinite possibilities." โจ
Thank you for checking out my Cub3D engine! I hope you enjoy exploring the demos as much as I enjoyed building them. ๐