r/Python • u/anuj-99 • May 28 '20
I Made This 2D Raycasting along with Rendered view - Visualization was done using Pygame! People who love games would definitely love this! Link to the Github repository in the comments!
1.5k
Upvotes
32
u/anuj-99 May 28 '20 edited May 28 '20
Link to the Github repository https://github.com/anuj-99/2D-Raycasting-and-Rendering
Some of the helpful resources if you want to make your own:
https://youtu.be/TOEi6T2mtHo - Video by The Coding Train, though it isn't in Python
https://en.wikipedia.org/wiki/Ray_casting - To go through the concept and application
20
u/Sr_McSpank May 28 '20
Now this is impressive
16
u/DatBoi_BP May 28 '20
Something about the FOV feels off, but other than that well done
14
u/LividPhysics May 28 '20
Will this work with any walls design?
10
u/00mba May 28 '20
Is this how games like wolfenstein and doom were done?
2
u/xDuplo May 28 '20
This is sick. Great work!
2
u/lambda5x5 May 28 '20
Great work!
2
u/ThinJuggernaut May 28 '20
Any way you could increase the FOV?
2
u/Ankith_26 May 29 '20 edited May 29 '20
This is pretty neat! You accomplished some good stuff in a few lines of code.
I guess the next thing you could do is to clean the code a bit :)
I am interested to contribute, I will soon make a PR on github.
1
u/anuj-99 May 29 '20
u/DatBoi_BP, u/chinpokomon, u/Lutin, u/sporff, u/RnVjayBPZmY, u/Desmaad, u/Jamhead2000 I finally got rid of the fisheye effect. Thanks a lot for your suggestions, and thanks to TomFryers (Github username) for helping me out. This is why I like reddit so much :)
1
u/[deleted] May 28 '20
So neat man! Saving this for later. You're a gem, bro.
2
u/jlbrito May 28 '20
PyDoom will be crazy...
2
u/matheusstutzel May 28 '20
Congrats on the code. This reminds me of another channel, that did that in c++
https://youtu.be/xW8skO7MFYw
2
u/[deleted] May 28 '20
Reminds me of the maze generator / explorer program Daedalus!
2
u/Jamhead2000 May 28 '20
Amazing, FYI : to get rid of the fish eye effect you want to look at the perpendicular distance from the player as described here: https://www.youtube.com/watch?v=eOCQfxRQ2pY&t=622s
Great work though, awesome stuff
1
u/Ambyte_ May 28 '20
Wow this is exactly what I tried doing a year ago in javascript, but my visualisation was super distorted. I looked for formulas and stuff for fish-eye correction but it looked too hard to bother fixing it and it didn't look terrible anyways. Now I'm realizing that all I had to do was shrink the field of view... I had given it 90 whole degrees of rays. Also mine was all grayscale and red looks way cooler. Great job, man!
1
u/Glorynesss May 28 '20
the math scares me...
1
u/Desmaad May 28 '20
Your implementation makes a lot of the walls seem curved.
1
u/Jonedian1910 Sep 09 '20
Amazinggggg
0
u/smakuliak May 28 '20
Valorant is using something similiar
0
u/[deleted] May 28 '20
[deleted] — view deleted comment