Make Your Own Raycaster Part 1

  Рет қаралды 403,040

3DSage

3DSage

4 жыл бұрын

I'm happy to share my raycaster video with you! I hope you learn something, or find it interesting and stay tuned for more fun videos!
Install C and OpenGL • Install Dev C++ and Op...
Minecraft GBA • GBA Minecraft | Pushin...
Zelda GBA • Zelda 3D Demake | Game...
Part 2 with textures! • Make Your Own Raycaste...
Doom tutorial • Let's Program Doom - P...
Download this source code, but follow the video first!
github.com/3DSage/OpenGL-Rayc...
If you make this, let me know and I'll add your link here.
Roberto Abad Followed my tutorial! Check out his Raycaster!
/ 1254070338410995713
Witcher but it's a game from 1990
• Witcher but it's a gam...
Raycaster's shown in this video
Synthes 3D • Synthes 3D - Levels 5-...
Wolfenstein 3D • Video
8Bit Killer Gameplay • 8Bit Killer Gameplay
16 Bit Ray Caster • 16 Bit Computer Ray Ca...
Swinger Engine • Swinger Engine - Load/...
Dracula • Bram Stoker's Dracula ...

Пікірлер: 1 300
@LydiaApril
@LydiaApril 4 жыл бұрын
I don't know anything about video games but it is really neat to see how the programming is done. Love your water sponsor 🤣
@3DSage
@3DSage 4 жыл бұрын
Hi Lydia! Thank you! I was hoping to hear someone say that. I tried to make this video fun to watch for all viewers. Those are my friends and they had many creative ideas that I really liked filming and editing. Maybe they will be in the next sponsor video too. :)
@kris_0520
@kris_0520 4 жыл бұрын
3DSage I demand a line of purified water be made that has that label.
@3DSage
@3DSage 4 жыл бұрын
@@kris_0520 I would like to see that too! :)
@iamarchibald
@iamarchibald 4 жыл бұрын
@@3DSage water has recently released a new type of water called sparkling water so they might want you to promote that. Sparkling water is like normal water but it sparkles which is pretty insane
@superhs
@superhs 4 жыл бұрын
@@iamarchibald It also kinda tastes like TV static, which I didn't even know had a taste
@migolas8222
@migolas8222 4 жыл бұрын
I can't find the *WATER* link
@thacuber2a03
@thacuber2a03 4 жыл бұрын
Hahahahhahahahahha waaaaaaat theeeeeeeeeeeee fuuuuuuuuuuuuuuuccccccccc
@shiiiguthewise6778
@shiiiguthewise6778 4 жыл бұрын
water.com
@jacobtvadventures
@jacobtvadventures 4 жыл бұрын
Thanks, Whumchy!
@c4nn0n17
@c4nn0n17 4 жыл бұрын
@@shiiiguthewise6778 no referrers link for discount tho awww
@Ten2
@Ten2 4 жыл бұрын
C4NN0n use code H20 when buying for discount
@vollkorncrafter409
@vollkorncrafter409 4 жыл бұрын
The dislike is from Unity
@SDFTDusername
@SDFTDusername 4 жыл бұрын
i use unity but didnt disliked
@user-iu8ps1yo1w
@user-iu8ps1yo1w Жыл бұрын
Lol
@Coolae450
@Coolae450 Жыл бұрын
You don’t like unity so you made your own raycaster?
@Coolae450
@Coolae450 Жыл бұрын
Yknow there is like hundreds of game engines at are very different from unity
@geodebreaker
@geodebreaker 11 ай бұрын
@@Coolae450r/wooooosh
@JuliusHahaha
@JuliusHahaha 4 жыл бұрын
Damn dude, this is some quality content
@3DSage
@3DSage 4 жыл бұрын
Thank you! I'm happy to hear that :)
@JustCallMeKumori
@JustCallMeKumori 4 жыл бұрын
Raycasting seems really complicated. But this video really makes it seem way less scary!
@3DSage
@3DSage 4 жыл бұрын
That was my goal! I wanted to take it step by step so it's easier to understand the concept. :)
@nickpavloff8977
@nickpavloff8977 4 жыл бұрын
Its probly how our brains see the world lol
@mr.cantillasz1912
@mr.cantillasz1912 4 жыл бұрын
I'm a ICT student,this is medium hard,maybe....oof😐
@quickscopesheep5994
@quickscopesheep5994 3 жыл бұрын
its really simple its just to do it it requires a shit ton of complex maths
@iamlordstarbuilder5595
@iamlordstarbuilder5595 3 жыл бұрын
For someone like me, it easy! I’m doing it lower level than OGL, rather X11 (Linux-only)
3 жыл бұрын
00:00 Intro 00:17 Games that Use Raycasting 00:48 Prolog 00:57 Sponsor 01:27 Introduction 02:42 Beginning of the Coding - Gray Window 03:14 Coding - Player and Top View 04:01 Coding - Map and Top View 05:14 Coding - Changing player's control to FPS like 06:43 Coding - Casting Single Ray (for horizontal collision/horizontal check) 09:49 Coding - Vertical Line Check (VLC) 11:09 Coding - Combining HLC & VLC to Calculate Ray's Length 12:33 Coding - Casting More Rays 13:43 Coding - Visualizing the Rays in "3D" 15:09 Bonuses
@rxn7
@rxn7 3 жыл бұрын
who asked
3 жыл бұрын
@@rxn7 I personally came back to this video many times when I was writing my own shader based on this (just comparing notes tbh) in ShaderToy and it was kinda annoying always trying to find a specific part of the video and this makes it much more easier I think...
@gutsarc
@gutsarc 3 жыл бұрын
@@rxn7 I did
@blackflame_
@blackflame_ 2 жыл бұрын
@@rxn7 joe mama
@chrisk6656
@chrisk6656 Жыл бұрын
@@rxn7 i love you
@ljreinworth
@ljreinworth 4 жыл бұрын
13:46 "And by we, I mean... Umm... Leo." I feel attacked.
@TheTiznone
@TheTiznone 3 жыл бұрын
Damn it, Leo, you had one job
@leobozkir5425
@leobozkir5425 3 жыл бұрын
Me too.
@ljreinworth
@ljreinworth 3 жыл бұрын
@@leobozkir5425 Hello Leo, I'm Leo. Nice to meet you.
@geko2867
@geko2867 3 жыл бұрын
@@ljreinworth hello again :D
@ljreinworth
@ljreinworth 3 жыл бұрын
@@geko2867 hey there again, Rako! You're not intentionally looking for my comments are you? It's been a while, how are you?
@GabrielMartins-wp6ps
@GabrielMartins-wp6ps 4 жыл бұрын
Man, idk if you are going to read this, but really thanks, I was trying to create a raycaster for a very long time and i finally created a functional one with the help of your video
@3DSage
@3DSage 4 жыл бұрын
I'm very happy to hear that! I'm so glad I could help. And thank you for the nice comment.
@gambe96
@gambe96 4 жыл бұрын
His voice really matches the cat so well
@elvirus6994
@elvirus6994 3 жыл бұрын
We totally need the 2nd part of this tutorial, It's the best raycasting tutorial I could find, and it would be super cool to have all the features you mentioned, keep up with the great work!
@Nassos__
@Nassos__ 4 жыл бұрын
Really makes me want to pick up C and start coding. Please do make a part 2, your explanations are clear and to the point
@OrangeDied
@OrangeDied 2 жыл бұрын
pro tip for anybody following this tutorial: don't just copy the code, attempt to understand why each math thing needs to be there and how it contributes. you actually learn what's happening and you feel a lot smarter by the end
@runninggames771
@runninggames771 Жыл бұрын
I feel like this would be easier if his variable names were longer then 2 characters
@elllieeeeeeeeeeeeeeeeeeeeeeeee
@elllieeeeeeeeeeeeeeeeeeeeeeeee Жыл бұрын
Maybe it would be more helpful if his code actually compiled
@OrangeDied
@OrangeDied Жыл бұрын
@@elllieeeeeeeeeeeeeeeeeeeeeeeee compile deez nuts
@nood1le
@nood1le 5 ай бұрын
That's right. Which is what this video failed to do.
@arturpaivads
@arturpaivads 4 ай бұрын
I have to assume that when trigonometry started to roll I just copied and pasted. But otherwise makes sense. Also, I'm building with SDL, not OpenGL, so copy and paste is not an option. And I'm using variables that make sense, not Rx, ry, MX...
@Xilefian
@Xilefian 4 жыл бұрын
Interestingly ray-casting is actually pretty darn inefficient, even on a 286 in 1992. John Carmack's foreword for Fabien Sanglard's book mentions this - how a Doom style raster engine would have been more efficient (hence Wolf3D on SNES uses a BSP tree raster engine, rather than ray-casting). For your GBA tutorial if you want to avoid devkitPro I'm actually currently writing a new CMake based toolchain that uses ARM's GNU embedded toolchain - complete with debugging in Visual Studio + mGBA and compatible with any CMake IDE. Might be a lot simpler than asking people to install devkitARM.
@3DSage
@3DSage 4 жыл бұрын
Hi there! That is interesting. Raycaster's are pretty fast when compared to other techniques. I have looked into BSP trees but they have some limitations too. Maybe I can make that video too. I'll have to check out that book. I'm glad you are making your own and I look forward to your videos!
@Ehal256
@Ehal256 4 жыл бұрын
​@@3DSage The problem is that while raycasting is simple, it requires many redundant raycasts for most visible walls, so it doesn't take into account spatial locality (i.e. if a screen pixel 1 is covered by wall A, other screen pixels near by are likely to also be covered by wall A). Doom finds the list of all potentially visible walls up-front (up to 256 walls, I think), and handles occlusion on a per-wall basis, rather than per-screen-column. This is how it was able to support much greater geometric complexity.
@captainphoton1693
@captainphoton1693 4 жыл бұрын
It's may be inefficient but it's so simple to make (but realy long) that you can run a 3D maze in a game like geometry dash using this technique
@johnleorid
@johnleorid 3 жыл бұрын
@@Ehal256 You are wrong. He is using a grid and does not check all available walls. What you mean is a polygon-based Raycaster, everything you said is only true for Polygon (Triangle) Raycasters. If you want to check all triangles in space with raycasting, you have to loop through them. In his specific case, there isn't a single triangle on the screen, it's basically a 2D game on a grid, he only checks the grid-tiles he needs to check, there is almost no redumdant check in his implementation - but he can't add height to his levels (or it would be very very difficult). (Doom had height in its levels (ramps, stairs, elevators))
@potatosapien8765
@potatosapien8765 3 жыл бұрын
@@3DSage I would love to see a video about bsp trees, it would really help me understand how they work a little bit better.
@nullrazor267
@nullrazor267 4 жыл бұрын
I've been looking for an explanation on raycasters for years, this is great! Thank you very much, please do a part 2
@ismyname_jep1394
@ismyname_jep1394 2 жыл бұрын
Not only is this very digestible educational information, it's also hilarious! Thanks for this content.
@3DSage
@3DSage 2 жыл бұрын
That's what I was hoping someone would so so thank you for the very nice comment! :)
@remty516
@remty516 4 жыл бұрын
Just finished making this in javascript and Html5, had to workaround some issues but it was two (long) days of fun. Thanks for making amazing videos that push people forward!
@dogbytez
@dogbytez 9 ай бұрын
I've been working on the same thing in javascript too! I know this comment is 3 years old, but would you be willing to share your source code?
@pauld1241
@pauld1241 4 жыл бұрын
Hi 3dsage! I'm a bit confused as to where to find the link to your sponsor.
@RubyPiec
@RubyPiec 4 жыл бұрын
@Austin Entenmann Thanks!
@remty516
@remty516 4 жыл бұрын
@Austin Entenmann Took me 2 minutes to load that site
@thatboredinternetwanderer140
@thatboredinternetwanderer140 3 жыл бұрын
@Austin Entenmann Cool, thanks! Ima buy Water tm right now
@velkex6050
@velkex6050 4 жыл бұрын
Can’t wait for the part 2! Also, I can’t understand how such a KZfaq like you still do not have 500000 subscribers, you really deserve more!
@ryandracuscodesgames8418
@ryandracuscodesgames8418 Жыл бұрын
This was a very excellent video for an introduction to rudimentary 3D graphics for programmers! After 4 hours of refactoring the code in Java using the standard graphics library and digesting the math, I was finally able to do everything in the video! When I finish the other tutorials, practice it, and finish my own game, I'll be sure to tag you and give you all the praise in the world. I can't thank you enough. No video details this early technique in Java on KZfaq, so I'm glad that your code is so easy to transport over to Java!
@cypherparadigm3428
@cypherparadigm3428 Жыл бұрын
ngl i appreciate you not slowing the video down to show the code step by step but rather explained what you were doing right along with it. Makes it so you can work at your own pace if you choose to follow along and i respect that.
@imaginaryfanboy
@imaginaryfanboy 4 жыл бұрын
I really appreciate your efforts into explaining coding in a way anyone can understand!
@raminote5726
@raminote5726 4 жыл бұрын
part 2 ? when when ? make a full series !
@sassafrasofficial3695
@sassafrasofficial3695 4 жыл бұрын
Yes
@connorconnor2421
@connorconnor2421 4 жыл бұрын
part 2? when when? make a full series!*
@MrJosch97
@MrJosch97 3 жыл бұрын
Yes
@jonnybonbon91
@jonnybonbon91 3 жыл бұрын
I really want at least a part 2
@ahmetemiruludag
@ahmetemiruludag 3 жыл бұрын
He did a one now, you can check it!
@gangstasteve5753
@gangstasteve5753 4 жыл бұрын
thanks so much for making this video. i have been trying for an EXTREMELY long time to find out how to get rid of that dang fish eye effect. I was doing all of this the naive way also, so you are really helping me optimize it.
@selvamthiagarajan8152
@selvamthiagarajan8152 Ай бұрын
Simply Brilliant, Brilliant, Brilliant ! You made it look so easy, interesting, and inspiring.
@EvilTim1911
@EvilTim1911 Жыл бұрын
I love this series but it would be a little easier to follow the code if the variable names were just a little bit more descriptive. I know short variable names are more convenient but when we end up dealing with a bunch of variables named px, py, ry, rx, mp, my, mx, ra, pa etc. it's a bit tough leaving mental notes what each one was short for.
@jackmarquette1351
@jackmarquette1351 Жыл бұрын
yes I was having a hard time so I used chat gpt to help me and explain some of it, it worked surprisingly well
@mariocamspam72
@mariocamspam72 Жыл бұрын
@@jackmarquette1351 Ugh.
@alvinbontuyan8083
@alvinbontuyan8083 Жыл бұрын
@@mariocamspam72 it's the exact same as being helped by a youtube video lmao
@elllieeeeeeeeeeeeeeeeeeeeeeeee
@elllieeeeeeeeeeeeeeeeeeeeeeeee Жыл бұрын
@@mariocamspam72 hurr hurr ai bad
@maykolmesarodriguez1379
@maykolmesarodriguez1379 Жыл бұрын
Comment: this works to remember You what's do the program that you're programing and do not use mental notes 😅
@dittot
@dittot 4 жыл бұрын
really engaging tutorial though
@RenderScape
@RenderScape 8 ай бұрын
Just wanted to say thank you for making this. I've just used it for a project I'm working on and it helped immensely.
@tyleri.4219
@tyleri.4219 4 жыл бұрын
Amazing tutorial! Simple and entertaining. I’d love to see a part 2!
@Dr.W.Krueger
@Dr.W.Krueger 7 ай бұрын
Nice video. :) Made one back in 1986 on an Amiga 1000, assembly instead of C/C++.
@3DSage
@3DSage 7 ай бұрын
Hey that's really cool and very impressive! :)
@PinkeySuavo
@PinkeySuavo 13 күн бұрын
Are you still programming? I was -10 years old back then.
@InnerTranquility
@InnerTranquility 4 жыл бұрын
This is very well made! Great job sir!
@3DSage
@3DSage 4 жыл бұрын
Thank you for the nice comment!! :)
@potatosapien8765
@potatosapien8765 3 жыл бұрын
Thanks for making this video! I couldn't find a lot of information about how a raycaster works but your video helped me be able to make my own implementation in python.
@Ticbow
@Ticbow 4 жыл бұрын
We definetly need a part 2 to this, it was very good!
@samwilson5544
@samwilson5544 4 жыл бұрын
This cleared something up for me, so thanks ☺
@3DSage
@3DSage 4 жыл бұрын
That's what I wanted to hear so thank you for your comment! :)
@TheAnakamex
@TheAnakamex 4 жыл бұрын
Now I want to make one myself but maybe in JavaScript or something like that to try how far I could push the idea
@3DSage
@3DSage 4 жыл бұрын
Absolutely, you can since this is easy to port between languages. If you post it, send me a link! :)
@Trekeyus
@Trekeyus 4 жыл бұрын
@@3DSage tempting to try porting it to python.
@suptnt2004
@suptnt2004 3 жыл бұрын
@@Trekeyus me too, but I got stuck at 9:30 how far are you?
@SINDIRELLA-ti1kl
@SINDIRELLA-ti1kl 3 жыл бұрын
@@suptnt2004 I'm porting it to GML... stuck at the same spot
@Trekeyus
@Trekeyus 3 жыл бұрын
@@suptnt2004 stuck getting motivation to even start keep putting it on the back burner
@kellybmackenzie
@kellybmackenzie Жыл бұрын
Your channel is amazing. These videos have been my drug for a while now. I LOVE THIS
@alexl5941
@alexl5941 3 жыл бұрын
Followed this tutorial to make this in java without a game engine, works very well. Thank you! Will be checking part 2 and will be adding some features of my own as well maybe.
@ItsRamzi
@ItsRamzi 2 жыл бұрын
This is a great tutorial. I implemented it along in Java. So a 17 minute video took more than an hour to get through. I had some problems, though. For example, when running before certain parts were implemented I would get errors that you didn't show getting. In particular there was an index out of bounds error for an array, on the line that used map[mp]. You would later in the video add the condition mp>0 to remove that error. I anticipated that. But it might suck for people implementing along to see that much later, rather than earlier. My final product came out pretty good, but it's a little glitchy. Sometimes I have most rays properly coming out of the 60 degree line of sight, but a few rays coming out of the back of the character's head, in the other direction. I don't yet know what accounts for this. Maybe if I copy and paste your Github source code and then convert it to Java, it will correct whatever error there is. Maybe it is a typo, as I made a few of those already. But the previous typos were easy for me to diagnose and fix. This one seems more confusing to me. I also wonder if your part 2 video won't just correct this automatically, if I am loading a texture rather than drawing a line. But I suspect that the error will remain for as long as any rays are being cast backwards. One part that I thought might cause the problem is... You have two ifs, one which checks a less then, and one that checks a greater then. But this ignores the case where the lines are equal. I had originally coded it with an else rather than two ifs, but I changed it to two ifs thinking that might fix the problem, but it didn't. Hmm... Now that I think of it, maybe this could be the cause of the backward ray cast. If the first if sets the ray correctly... No wait, that doesn't make sense. Hmm... Checking your Github source now, you only have 1 if where you had 2 ifs in the video. The two ifs compared disH and disV. But you only have one condition for that in your Github source, and you set one to be the other if it's longer. I wonder if that'll correct my backwards casting rays. Edit: Yep, that fixed the backward casting rays. But I still have rays traveling through walls sometimes. Weird. I bet if I just copied and pasted your Github source and converted it to Java it'll work. Edit: Translating from your Github source fixed the problems.
@AwesomePowerCat
@AwesomePowerCat 2 жыл бұрын
thanks this helped me fix the backwards casting issue
@ItsRamzi
@ItsRamzi 2 жыл бұрын
@@AwesomePowerCat :)
@notNull..
@notNull.. Жыл бұрын
Min sharing it? I’m trying to do it on javafx but I’m stuck on casting the lines from the center of the rectangle and getting them to move along with it. It would mean a lot
@eyeindasky3805
@eyeindasky3805 3 жыл бұрын
For those using Ubuntu, compile in the terminal like this: g++ original_file_name.cpp -o file_rename -lGL -lGLU -lglut and then just: ./file_rename Luck!
@3DSage
@3DSage 3 жыл бұрын
Thank you for letting people know! :)
@johnnysavior4538
@johnnysavior4538 2 жыл бұрын
Finally a good raycasting explanation that I can actually follow along. Im using your video for creating a raycasting game on pygame. Thank you!
@Aresplaysgd
@Aresplaysgd 2 ай бұрын
This tutorial is amazing, I wanted to make a 3d game in pygame, i got all the way to ray casting, but 3d rendering seemed so complicated. Then after hearing that its just rectangles, I attempted to make it all, and it worked firat time, and i exploded in happiness. Gonna learn some more soon. Thanks alot for this
@trashtrash2169
@trashtrash2169 4 жыл бұрын
wow... you make it sound simple... i feel like i could do it with the minute little programming knowledge i may have with just a bit more effort... and tutorials.
@3DSage
@3DSage 4 жыл бұрын
Yes! I was hoping to inspire anyone to make this. It's so rewarding when it works and you can edit your own levels. Please do give it a try! :)
@leosefcik
@leosefcik 4 жыл бұрын
Hey ur the guy that wanted minecraft on GBA
@trashtrash2169
@trashtrash2169 2 ай бұрын
Lol.
@qu765
@qu765 4 жыл бұрын
The only problem with this is that walls can only be in certain places. I made one were the rays just detect with the walls them selfs. (With a loop the find the collision with each wall and finishes on the closest distance) My method is much more efficient for scenes that are big or have walls in any direction. However, for like a big tightly cramped maze, yours would be better. (more walls, less space, straight walls) But I could add in chunking and then there would be almost no situations where mine is worse. My method requires more math, however. How it does it is that it to the ray into a y=mx+b equation with a starting point and each wall into a y=mx+b with two endpoints. Then it performs solving a linear equation of the two to find the intersection point. It makes sure it is valid (correct side of the placer and not above or below the wall). Then finally it calculates the distance to the point. Does this to all the walls then it will find the smallest distance and that is the final distance the ray has traveled. There are also more optimizations that could be done to both yours and I did to mine, in which you only shoot out certain rays in the direction that you need to (this a good description of it ncase.me/sight-and-light/ ). One last thing: whenever I said my method, I do not mean I am the very first to use it or am I trying to talk about how mine is so much better than everything else, it is just that I could not find a better way to say it.
@StevenJonWest
@StevenJonWest 5 ай бұрын
By far the most educational and awesome video I’ve seen in a while! Thanks for sharing this, excited to try and code this myself! 👨‍💻
@amanciofelipezanidasilva148
@amanciofelipezanidasilva148 Жыл бұрын
thx so much for sponsoring this video
@majorcrng
@majorcrng 4 жыл бұрын
your sponsor “water” convinced me to go down at 3am and drink “water”
@RubyPiec
@RubyPiec 4 жыл бұрын
*w a t e r*
@jojolafrite90
@jojolafrite90 4 жыл бұрын
The real new interesting thing invented by ID was the sectors, if I'm not mistaken.
@MinchanLyoko
@MinchanLyoko 2 жыл бұрын
Thats right but in my opinion build engine is better 😊
@dreamhollow
@dreamhollow 2 жыл бұрын
I don't mean to sound like a heathen but I was actually following this tutorial using Visual Studio and SFML. Your instructions were still clear enough to get a good idea of what to do. Thank you immensely. This is a great tutorial.
@lsk-nf7um
@lsk-nf7um Жыл бұрын
I sure love your sponsor. I couldn't live without them!
@battlq6421
@battlq6421 4 жыл бұрын
Hey I am having lots of trouble with the code crashing when i am at the point that I have to scan for lines. Could you please send me a link to the source so I can check what I am doing wrong
@spigui500
@spigui500 4 жыл бұрын
Please do a part 2!!!!!
@3DSage
@3DSage 4 жыл бұрын
Ok I will :)
@iDontProgramInCpp
@iDontProgramInCpp 4 жыл бұрын
@@3DSage That part 2 seems to take a while to make
@ChickenScratch
@ChickenScratch 4 жыл бұрын
Gosh a part 2 would be amazing. I've already watched this video at least 20 times and used it to code a ray-casting engine.
@ThePikmania
@ThePikmania 4 жыл бұрын
this is really cool, thanks 3DSage. Relatively little code and yet such an effect
@darwinandloki5559
@darwinandloki5559 2 жыл бұрын
Can someone explain a bit more about -1/tan(ra) at 7:02. What does the negative inverse of tangent do exactly and what happens when you multiply (py-ry) by the negative inverse of tangent. Sorry if this is a simple concept I'm just trying to understand a bit more :)
@RyanBlecher
@RyanBlecher Жыл бұрын
This was the fundamental piece missing from this video for me. I struggle with the math. Drawing it and revisiting the trig functions helped me. I also think arctan is incorrect and 1/tan(ray_angle) is actually the cotangent(ray_angle)? If you think of cot and tan as ratios and how all the trig functions relate to the unit circle, the multiplications start to make sense because the values cancel out. 1. (player_y - ray_y) aka: the Y coordinate is the sin(ray_angle) of the triangle you're trying to solve. 2. cot can be expressed as cos/sin 3. sin * cos/sin, the sin cancel out and you're left with cos, which is the ray_x you're looking for, but in the context of your ray angle. The player_x needs to be added so the ray_X point is offset the correct amount of pixels. Use this same approach with the vertical intersections to understand which tan (aka sin/cos) is used instead.
@User-oh8vi
@User-oh8vi 8 ай бұрын
He fixed the negative at the code he uploaded to Github
@gabo9476
@gabo9476 4 жыл бұрын
Your name doesn't lie, amazing video! Can't wait for part 2 PS: There is a but... don't like the sponsor, water is such a useless product, i can live perfectly without it...
@3DSage
@3DSage 4 жыл бұрын
Thank you for saying that! And good for you. You must be an alien. Welcome to Earth. :)
@hungrysparrow
@hungrysparrow 4 жыл бұрын
This is awesome! Hope you do a whole series of these.
@shreeshmeghna7158
@shreeshmeghna7158 3 жыл бұрын
Thanks so much for this video! It inspired to write my own ray casting engine in pygame, and you really made me realize how easy it is to do so!
@x4d
@x4d 4 жыл бұрын
hey, im having issues with creating the rays. is there a discord i could join for someone to help me out?
@goldrn208
@goldrn208 4 жыл бұрын
same
@Darksoulmaster
@Darksoulmaster 4 жыл бұрын
What the hell where is the promotional code for the water! This is clickbait! Disliked, unsubbed.
@TheRabbitPoet
@TheRabbitPoet 4 жыл бұрын
Thank you so much for the tutorial it was really helpful. It would have taken me ages to figure this out all by myself, but by using this model as a starting point I can customize it and add extra features, for now I'm adding collisions and some wall designs (don't know how to add textures so I'm writing them with code)
@KhaliliStudios
@KhaliliStudios 4 жыл бұрын
Awesome video loved the sponsors and the “and by we I mean... “ 😂 keep it up man!
@atx4dt
@atx4dt 3 жыл бұрын
Love this! I don't fully understand all the math yet :P looks like there is a small mistake around 8:33 with your second typecast on line 70 though. :)
@laz3664
@laz3664 7 ай бұрын
haha I thought I was the only one that didn't get all the math, I'm talking about his dda algorithm
@MatejGames
@MatejGames 4 жыл бұрын
Can i get a coupon code for my water?
@3DSage
@3DSage 4 жыл бұрын
Waiting on that sponsorship check to come in ;)
@xWourFo
@xWourFo 4 жыл бұрын
I love that, I can't wait for part two!
@funguslars
@funguslars 3 жыл бұрын
I am in the process of writing my own game engine in DirectX and I stumbled upon this video. This is super useful for me! Thank you!
@3DSage
@3DSage 3 жыл бұрын
I'm glad to hear that! I hope you post your game engine when you get it working. I hope to see it!
@thatanimeweirdo
@thatanimeweirdo 4 жыл бұрын
Interesting, as a high-level programmer, I always thought C was much harder to understand!
@ArtUniverse
@ArtUniverse 4 жыл бұрын
C is as hard as you make it out to be. You can write complex programs with simple code.
@deanolium
@deanolium 3 жыл бұрын
C really isn't that complicated at all. The only things to be aware of is the need to manage memory. Otherwise you can end up with memory leaks which can ruin your day. These are pretty easy to avoid unless you're doing complicated programs though.
@newtechandcoding2213
@newtechandcoding2213 4 жыл бұрын
can you please give me a link to the complete source code?, my code isn't working and I want to see if I can fix it.
@SBX-uf3in
@SBX-uf3in 3 жыл бұрын
same here bud
@vriska222
@vriska222 3 жыл бұрын
same
@SapphFire
@SapphFire 4 жыл бұрын
Really well made and was interesting to watch. I'll look forward to the GBA tutorial.
@AnLAdCearbhaill
@AnLAdCearbhaill 4 жыл бұрын
Hit us with that second part please! Also, could you highlight the changes you make as you make them? You've really come a far way since your first few tutorials but I find that for some people, who would be total beginners, they could miss some of the quicker changes you make! Keep up the great work man! :)
@dittot
@dittot 4 жыл бұрын
Download to the GBA raycaster?
@3DSage
@3DSage 4 жыл бұрын
I'll upload that somewhere for you to download soon. And in the next video i'll teach you how to program a GBA game. :)
@dittot
@dittot 4 жыл бұрын
@@3DSage Sounds great, would love to start programming my own GBA games. Can we expect downloads for Minecraft & Zelda too (even if they are in early stages/are unfinished at the moment)?
@pegfun16
@pegfun16 4 жыл бұрын
When I compile at 9:19, the ray doesn't show up.
@susq_345
@susq_345 4 жыл бұрын
make sure you check that the ray only collides with white wall
@chxry9670
@chxry9670 4 жыл бұрын
make sure you call drawRays2D() in your display function
@markokarsai5705
@markokarsai5705 4 жыл бұрын
Change the drawRays3D to drawRays2D and add drawRays2D(); under drawMap2D();. I hope this helped. 😉
@nitrogenthrone1778
@nitrogenthrone1778 3 жыл бұрын
I am to
@pegfun16
@pegfun16 3 жыл бұрын
@@chxry9670 I did then the ray pointed backwards and it crashed.
@enricmm85
@enricmm85 3 жыл бұрын
Your sponsor literally keeps me alive. Thanks sponsor.
@fabioazevedo2048
@fabioazevedo2048 3 жыл бұрын
Excellent job, @3DSage! Your video is informative, straightforward and even fun to watch (thank the cat - Leo, right?). I got really inspired! Thank you for putting this all together and sharing with us.
@sh4dow176
@sh4dow176 3 жыл бұрын
Where’d you get the “code.cpp” file at the start? And when I typed it out myself and compiled and ran it opens “glut.h” and says (in the compiler tab at the bottom) “483 c:\program files (x86)\dev-cpp\mingw32\include\GL\glut.h undefined reference to `_glutInitWithExit@12’ “ what does this mean and how do I fix this? I know I’m late but i really want this to work! Thanks in advance! EDIT: I fixed it by adding a ‘#define GLUT_DISABLE_ALTEXIT_HACK’ but now it has a red bar on line 7 (now 8) and an error saying “undefined reference to `_imp_glClear@4’” I’ll try to fix it on my own... I’ll update if I fix it and more errors pop up! Guess this comment is my journal now!
@arieyorsson3191
@arieyorsson3191 3 жыл бұрын
No idea if you're still facing this error, but you need to link with the opengl libraries
@emneo-dev
@emneo-dev 4 жыл бұрын
You really need a coding style dude, the code is almost unreadable :/
@tdif3197
@tdif3197 3 жыл бұрын
What do you mean, like five statements all in one line, all using combinations of unexplained two-letter variables isn't a style?!
@user-zu1ix3yq2w
@user-zu1ix3yq2w 3 жыл бұрын
@@tdif3197 I feel right at home reading his code. Stop crying, guys.
@pointers2010
@pointers2010 3 жыл бұрын
that code is actually really clean for a fast video, if you dont know how to program, then it would be very hard for you to read it :/
@cybroxde
@cybroxde 3 жыл бұрын
@@pointers2010 It's annoying to read, even if you know how to program. Formatting code properly just saves everyone lots of mental capacity understanding it. Good luck making sense of that code without watching it being written, I guarantee you waste a few minutes every segment.
@pointers2010
@pointers2010 3 жыл бұрын
@@cybroxde good point, but when i started coding i was a bit trash, so i got into reading this type of code
@Rokkuman10
@Rokkuman10 4 жыл бұрын
This was a very interesting video! Looking forward for the GBA tutorial!
@stevemuller3324
@stevemuller3324 Жыл бұрын
I love games but I know nothing about games engines. This vid was recommended to me by a couple of guys who work in the games industry. I watched this and found it simply fascinating. I was like "That's it? THat's a game engine?" but I was also like "That is so brilliant." Thank you for such a good explanation of how this works.
@_Ello
@_Ello 6 ай бұрын
your code is unreadable
@RemainingAxis565
@RemainingAxis565 2 ай бұрын
Still better than mine
@Dadertrix
@Dadertrix 4 жыл бұрын
i have a python background, and raycasting has always been interesting to me, but felt like it was too complicated, even though I don't understand a lick of the code, you made the math and concepts way to easy to understand! You are a fool for giving me this power
@RaposaCadela
@RaposaCadela 2 жыл бұрын
Fantastic! This is very straight-forward, I got it all to work in Godot. Except fixing the fish-eye effect, it works vertically, but horizontally it's going insane
@JickFincter
@JickFincter 4 жыл бұрын
please make a part 2 that is everything I want in a part 2 video about this stuff. Such a good video I love it.
@trykx5027
@trykx5027 4 жыл бұрын
I've recreated step by step your Raycaster game and it was really fun to do ! I'm hyped for the next episode :D
@elllieeeeeeeeeeeeeeeeeeeeeeeee
@elllieeeeeeeeeeeeeeeeeeeeeeeee Жыл бұрын
How? It doesn't work.
@pranavsreedhar1402
@pranavsreedhar1402 2 жыл бұрын
Thank you for the wonderful introduction to raycasting!
@ismaelbies
@ismaelbies 3 жыл бұрын
Nice work man! I am waiting for part two.
@datle5585
@datle5585 2 жыл бұрын
Please make more and more video like this!!!!!!!! Really appreciate how you break down very complex things for us
@SpencerYonce
@SpencerYonce 2 жыл бұрын
I just found you today and you like my favorite person already. I’ve also never heard someone else who does the S whistle with their teeth and tongue when saying some words. I’ve been messing with OpenGL and Vulcan the past few months and you are awesome
@ScruffyRuffy.
@ScruffyRuffy. 4 жыл бұрын
I just got recommended this video and can say I loved it
@potatopotato7561
@potatopotato7561 4 жыл бұрын
Damn, animations on point my man. Keep it up.
@farseendeveloper461
@farseendeveloper461 3 жыл бұрын
Love your way of presenting. Thanks for the video.
@kamranki
@kamranki 2 жыл бұрын
Awesome videos sir! Thanks for sharing this. I've always known the basics behind raycasting, but seeing it from a programmer's point of view is fantastic. Thanks again!
@3DSage
@3DSage 2 жыл бұрын
I'm working on Doom for my next video! :)
@totallynotabot151
@totallynotabot151 2 жыл бұрын
Thanks for the excellent explanation! I made a raycaster 30 years ago as a sample project to teach myself x86 assembly. The one part that I never got around to fixing was the fish eye effect. Turns out it's just a projection onto a plane perpendicular to the view vector, but I didn't know that at the time.
@3DSage
@3DSage 2 жыл бұрын
Thank you for sharing that! I'm impressed you did it with assembly. And yup, a simple cosine multiplication can correct the fish eye effect. Raycasters are a great program to make so I had to make this video to share it with people.
@SilentJ2602
@SilentJ2602 3 жыл бұрын
when i hit the ad i instantly subbed lmao this channel is great
@noahbarger1
@noahbarger1 Жыл бұрын
best sponsor. 100% recommend.
@kriglum0760
@kriglum0760 3 жыл бұрын
Can’t wait for part 2!!!
@maz5-870
@maz5-870 2 жыл бұрын
I dont think I could live if you didn't show me the sponsor. Thanks, singlehandedly saved my life!
@3DSage
@3DSage 2 жыл бұрын
Not all heroes wear capes. Some have bottled water :)
@tomasburian6550
@tomasburian6550 3 жыл бұрын
Ever since it came out, I was curious about how they made this game. I learned C at school at the end of the 90's and still it wasn't clear to me. This video finally tell me the truth, after all those years. Thank!
@lionelleeser3001
@lionelleeser3001 3 жыл бұрын
Amazing video. Gave me the will to try new stuff. Part 2 is needed, hope you're working on it.
@thedoctordowho2022
@thedoctordowho2022 3 жыл бұрын
Man, you are amazing ,very well done ahah.Thank you for the tutorial!
@SebastianSkadisson
@SebastianSkadisson 5 ай бұрын
Thank you so much. Raycaster for dungeons and mode seven for the overworld work so well on a tiny indi project to break out of the 2d and isometric mold.
@pexoto5093
@pexoto5093 Жыл бұрын
the water sponsor was just pure gold
@schrodingerscat1863
@schrodingerscat1863 Жыл бұрын
Loved the 'Sponsored by Water' ad, very funny.
Make Your Own Raycaster Part 2
13:46
3DSage
Рет қаралды 105 М.
How I Made a 3D Platformer in 2D Game Engine
21:23
ggenije
Рет қаралды 434 М.
Luck Decides My Future Again 🍀🍀🍀 #katebrush #shorts
00:19
Kate Brush
Рет қаралды 7 МЛН
3 wheeler new bike fitting
00:19
Ruhul Shorts
Рет қаралды 48 МЛН
Super gymnastics 😍🫣
00:15
Lexa_Merin
Рет қаралды 106 МЛН
Cheapest Bullet Time with a 9 Dollar Camera
6:59
3DSage
Рет қаралды 284 М.
Doom engine - Limited but still 3D
6:57
borogk
Рет қаралды 530 М.
Super Fast Ray Casting in Tiled Worlds using DDA
30:03
javidx9
Рет қаралды 175 М.
I Made a Neural Network with just Redstone!
17:23
mattbatwings
Рет қаралды 645 М.
Let's Program Doom - Part 1
25:13
3DSage
Рет қаралды 403 М.
Wolfenstein 3D's map renderer
14:49
Matt Godbolt
Рет қаралды 272 М.
Making Minecraft from scratch in 48 hours (NO GAME ENGINE)
16:38
This yearly values make your PC BRICKED
10:51
Daniel Myslivets
Рет қаралды 189 М.
How we fit an NES game into 40 Kilobytes
12:04
Morphcat Games
Рет қаралды 3,5 МЛН
Luck Decides My Future Again 🍀🍀🍀 #katebrush #shorts
00:19
Kate Brush
Рет қаралды 7 МЛН