Raycasting Tutorial (in Python)

preview_player
Показать описание
After 3 years since the last video I finally had the courage to make and upload another one. This time, about a subject that I was willing to teach for a long time: Raycasting

SOURCE CODE:

Chapters:
0:00 - Intro
0:57 - Introduction
1:43 - How it works
4:02 - Initial setup
9:43 - The Map
21:18 - The Player
39:14 - The Ray class
44:01 - The Raycaster class
58:25 - An introduction to the algorithm
1:01:25 - The Raycasting Algorithm
1:16:10 - Coding Horizontal Intersections
1:27:26 - Coding Vertical Intersections
1:38:07 - Drawing walls
1:45:46 - Final touches
1:53:36 - Ending

Music:
Vexento - Gone
Рекомендации по теме
Комментарии
Автор

I actually did a mistake on saying that Doom was a raycaster! Doom used a different technique called Binary-Space-Partitioning.

pythonista_
Автор

this is a really good tutorial, very simple to understand. but there is a mistake in min 48:45... if you have 6 rays, so you have 5 inner angles.when you calculate A (60°/6) the result is not the value of inner angles. if you check your graphic, you have a "big" 60° angle, made by five 10° "mall" angles, that should be 50° total. the correct value must be: A = FOV / (nums of ray - 1).
if you cheack your rays angles, the last one should be player.rotation_angle + FOV/2 and for sure that won't be true. on the screen you can't see the difference because you have 120 rays, so the last one has only a small "visual" difference of 0, 5°.

LeaTex
Автор

Great video, I have tried to make raycasters using blogs and videos write it in c++ and have failed several times, thanks to you finally I was able to fully understand how it works rather than just knowing it adds a a blocks width and height until wall is discovered.

mehulpaul
Автор

This was the perfect tutorial for me. Instant sub

thatguysudsy
Автор

finally im saving this bad boy until i learn moderngl so i can apply this so i feel better about myself

ohimdabiggestbird
Автор

Thanks man, you explanation is very good.

guilhermecampos
Автор

very informative and easy to digest
thank you

alokraj
Автор

Now make a raycaster from python in scratch

RxZrScratch
Автор

Great video bro, i wish i were as good at python as u, i started learning python a week ago and this is way impresive, new follow ❤

mansulol
Автор

1:04:14 This formula can be confusing if you're truly unfamiliar with how computer graphics work. In computer graphics, y increases downwards, so the opposite side is py - ay, not ay - py. If that's the case, why does the formula still work? Why isn't py - ay correct? It's because our y is flipped. Imagine you're looking up-right: tan(a) is negative (angles increase clockwise in graphics), and py - ay is positive. Positive over negative is negative, so instead of going right, we go left. The simple solution? Just multiply by -1, and suddenly ay - py works. Or, you could calculate tan(360° - a) to get the nice counterclockwise increment that's so popular in math books.

mokouu
Автор

great video, i honestly really liked it

edit in case you read the comment from a notification : i just realised a few seconds later why what i'm saying is dumb, flooring a number that's whole no matter what isn't the smartest thing to do

OutOfNet
Автор

1:40:04 where did 480 come from? Is it 960 / 2? why?

SmailOujaoura-tyui
Автор

I couldn’t import the settings module 😢

NhatNguyen-bidh
Автор

no. Doom was NOT a ray-caster! It used binary-space-partitioning.

whtiequillBj
Автор

Usando raycaster é possível fazer várias camadas como exemplo um andar para cima ou para baixo:? tipo o tibia?

andreyrvdev