Skip to main content
CF

Raycasting Engine Programming

18h 13m 33s
English
Paid

This course is designed to teach you how to build a complete raycasting engine from the ground up. By employing an algorithm similar to the one used in Wolfenstein 3D, you will create a detailed project using both JavaScript and C, encompassing player movement, 2D map views, 3D wall projections, textured walls, sprites, and various optimization techniques.

Course Structure

The course is divided into two key segments to provide a comprehensive understanding of raycasting engine development:

Part 1: JavaScript Fundamentals

In the first segment, we focus on using JavaScript to cover the theoretical and mathematical foundation of the raycasting algorithm. As a simple, high-level scripting language, JavaScript enables us to concentrate on the core concepts without getting bogged down by implementation intricacies.

Part 2: Advanced C Implementation

The second segment transitions into utilizing the C programming language to develop a compiled version of the raycaster. This part includes the integration of textured walls and sprites, alongside an exploration of essential optimization and performance enhancement techniques.

Required Tools

To participate in this course, you will need:

  • A web browser capable of running JavaScript.
  • A small C compiler.

These tools are cross-platform compatible, allowing you to follow along on Windows, macOS, or Linux!

Understanding the Raycasting Algorithm

The Wolfenstein 3D raycasting algorithm relies heavily on trigonometry. Ensure you have pen and paper ready for lectures. We'll thoroughly review and comprehend every formula we encounter throughout the course!

About the Author: Gustavo Pezzi

Gustavo Pezzi thumbnail

Gustavo Pezzi is a UK-based computer-science lecturer (Pikuma) and one of the most distinctive teachers working at the intersection of low-level programming and game development. His material is unusual in the modern course market for how deep it goes into the foundations: assembly, computer architecture, classical raycasting / rasterisation algorithms, and the math underneath modern graphics.

His CourseFlix listing reflects that range: courses on 3D Computer Graphics Programming, Raycasting Engine Programming, 2D Game Physics Programming, NES Programming with 6502 Assembly, PS1 Programming with MIPS Assembly & C, Atari 2600 Programming, Compilers, Interpreters and Formal Languages, plus C++ engine programming and Lua scripting. Material is paid and aimed at developers who want to understand systems from the ground up rather than ship CRUD apps.

Watch Online 96 lessons

This is a demo lesson (10:00 remaining)

You can watch up to 10 minutes for free. Subscribe to unlock all 96 lessons in this course and access 10,000+ hours of premium content across all courses.

View Pricing
0:00
/
#1: Introduction and Learning Outcomes
All Course Lessons (96)
#Lesson TitleDurationAccess
1
Introduction and Learning Outcomes Demo
12:19
2
How to Take this Course
02:59
3
An Overview of the Raycasting Algorithm
06:37
4
Raycasting or Raytracing?
07:10
5
Raycasting Limitations
03:11
6
A Review of Degrees and Radians
11:27
7
A Review of Sine Cosine and Tangent
16:44
8
Defining the 2D Map Grid
07:55
9
Coding the Map Class
16:54
10
Player Movement
06:33
11
Coding the Player Movement
23:13
12
Coding the Map Collision
10:18
13
Defining the Field of View
08:18
14
Coding the Field of View Ray Increments
16:32
15
Finding Wall Hit
07:49
16
Finding Horizontal Intersections
22:46
17
Finding Vertical Intersections
08:14
18
Coding X-intercept and Y-intercept
27:18
19
Coding the Horizontal Wall Intersection
12:10
20
Coding the Vertical Intersection
25:52
21
Fixing the Intersection Offset Error
07:41
22
Orientation as Angles or Vectors?
03:47
23
Wall Projection
06:50
24
Finding the Wall Strip Height
12:20
25
Visualizing the Minimap
06:03
26
Coding the Wall Rendering
15:24
27
Fixing the Fishbowl Distortion
13:32
28
Implementing Wall Shading by Depth
05:28
29
Bright/Dark Wall Sides
11:18
30
First Steps in C
12:29
31
Working with Makefile
13:56
32
Installing Visual Studio and SDL on Windows
14:46
33
Creating a SDL Window
22:00
34
SDL Rendering and Event Polling
12:24
35
Rendering SDL Rectangles
07:14
36
Game Loop Overview
06:32
37
Coding a Fixed Time Step Game Loop
09:51
38
SDL Delay
08:13
39
Drawing the Map with SDL
18:58
40
Player Movement and SDL Events
15:24
41
Implementing Wall Collision in C
03:46
42
Ray Struct and FOV
10:06
43
Translating the Horizontal Intersection to C
16:32
44
Translating the Vertical Intersection to C
17:07
45
Rendering Rays
09:08
46
The Color Buffer
27:48
47
Color Buffer Implementation
17:06
48
Freeing Allocated Resources
05:20
49
Creating the Wall Projection
17:38
50
Exercise: Ceiling & Floor Solid Colors
01:08
51
Ceiling & Floor Solid Color Implementation
02:02
52
Representing Textures
11:11
53
Creating a Texture Programmatically
08:12
54
Mapping Textures to Wall
07:26
55
Implementing Wall Texturing
20:25
56
Multiple Textures
07:26
57
Multiple Texture Code
14:53
58
Fixed Size Data Types
06:57
59
Using Fixed Size Integer Types
02:55
60
Libraries to Decode PNG Files
11:57
61
Loading External PNG Files
35:26
62
Activity: Field of View Distortion
05:31
63
Understanding the Angle Increment Distortion
11:53
64
Coding the Angle Increment Distortion Fix
08:12
65
Full Screen Window
28:28
66
Refactoring the Graphics File
36:22
67
Drawing Filled Rectangles
02:49
68
Refactoring the Map File
20:24
69
Refactoring the Ray and Player File
19:43
70
The Line Equation
15:18
71
Rasterizing Lines
22:25
72
Coding the DDA Line Algorithm
05:05
73
Refactoring the Wall Projection File
10:20
74
Creating a Type Definition for Color Values
07:11
75
Sending Parameters by Reference
04:53
76
Refactoring the Ray-Facing Code
06:42
77
Wall Texture Color Intensity
07:46
78
Coding the Texture Color Intensity
05:52
79
Raycasting Sprites
06:17
80
Sprite Type Definition
04:07
81
Coding the Sprite Typedef
24:57
82
Rendering Sprites in the Minimap
05:01
83
Identifying Visible Sprites
05:02
84
Coding the Visible Sprites
08:40
85
Finding the Sprite Distance
06:21
86
Normalizing Player Rotation Angle
04:51
87
Calculating the Sprite Projection Height
12:48
88
Calculating the Sprite X Position
04:15
89
Sprite Rectangle Position in the Screen
09:10
90
Displaying Textured Sprites
16:44
91
Activity: Sorting Sprites
02:27
92
Sorting Sprites by Distance
04:38
93
Sprites Behind Walls
06:12
94
Fixing the Sprite Fishbowl Distortion
03:30
95
Concluding our Raycasting Implementation
06:28
96
Notes on Look-up Tables
10:13
Unlock unlimited learning

Get instant access to all 95 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.

Learn more about subscription

Related courses

Frequently asked questions

What prerequisites are required before taking this course?
Before enrolling in this course, it is important to have a basic understanding of programming concepts, particularly in JavaScript and C. Familiarity with trigonometry and mathematical concepts such as degrees, radians, sine, cosine, and tangent is also necessary, as the raycasting algorithm relies heavily on these mathematical principles.
What will I build by the end of this course?
By the end of the course, you will have developed a complete raycasting engine. This includes implementing player movement, 2D map views, 3D wall projections, textured walls, and sprites. You will also apply various optimization techniques to enhance performance, similar to the technology used in the classic game Wolfenstein 3D.
Who is the target audience for this course?
This course is ideal for programmers who are interested in game development, particularly those who want to understand the fundamentals of building a rendering engine from scratch. It is suitable for learners who have a basic knowledge of JavaScript and C and wish to further their skills in implementing mathematical algorithms within a game context.
How does this course compare in depth to other programming courses?
This course provides a focused look at the implementation of a raycasting engine, specifically mirroring the technology behind Wolfenstein 3D. Unlike broader game development courses, it dives deeply into the mathematics of raycasting and the practical application of building rendering engines using JavaScript and C, offering both theoretical and hands-on coding experience.
What specific tools or platforms will I use in this course?
Throughout the course, you will use a web browser capable of running JavaScript for the initial theoretical part. For the advanced implementation in C, you will need a small C compiler. Additionally, the course involves using SDL for rendering and event polling. These tools are compatible with Windows, macOS, and Linux.
What topics are not covered in this course?
The course does not cover advanced game development topics beyond raycasting, such as full 3D rendering engines, game design principles, or networking. It focuses specifically on the raycasting algorithm, its mathematical foundations, and its implementation in JavaScript and C.
What is the estimated time commitment for completing this course?
The course consists of 96 lessons, which cover both JavaScript fundamentals and advanced C implementation. While the exact runtime is not specified, the course is designed to be comprehensive, requiring a significant time investment to thoroughly understand and implement the concepts taught. Students should allocate time for both learning the material and hands-on practice.