Log In  

Cart #wuyasudike-0 | 2020-09-21 | Code ▽ | Embed ▽ | No License
Hello :-)
I've recently started pico-8, and its been fabulous. I normally am a game developer in the Godot engine, so I don't have much experience with programming graphics, so I decided to make a raycaster. It went well, albeit with a lot of reconsideration about my life. Anyways, so I have everything mostly working how I expected it to have, except for this weird thing. The lines that I render to the screen as fine from a distance, but as I get closer to them they warp. This isnt the standard fisheye affect that other raycasters have, or maybe it is, but I dont think it is. I'm stumped. I'll be eternally grateful if anyone can figure out what I'm doing wrong.

edit: sO I removed the big fish-eye effect, that was easy and I already knew how to go about fixing that, but I still have the issue where going close to walls makes them warp inwards... It's weird.

Cart #rupoguwoye-0 | 2020-09-21 | Code ▽ | Embed ▽ | No License

P#82045 2020-09-21 10:40 ( Edited 2020-09-21 11:50)

At a guess, maths inaccuracies because of the accumulated additions/subtractions to dist. It may be worth calculating dist just once when you've worked out the intersection point.

P#82049 2020-09-21 14:24

Hang on,

singl*singl+cosgl*cosgl

should always be one (if mathematically perfect) anyway!

P#82050 2020-09-21 14:30 ( Edited 2020-09-21 14:31)

oh, my bad, I’ll fix that and see if it works. I’m really not great at math stuff.

P#82058 2020-09-21 19:30

Welcome to pico-8! I've done a couple of raycasters, and have found that the Lode Vandene raycasting tutorial is invaluable for this type of thing. You can find it here: https://lodev.org/cgtutor/raycasting.html
It goes over all of the math and gives code examples, which shouldn't be too hard to translate into pico-8. It's quite a long tutorial when following it for the first time, so feel free to take breaks to understand what's going on! good luck, I'd love to see what you do as you move forward.

P#82086 2020-09-22 04:32

Thanks for being so kind. I’ll follow the tutorial and make a functioning one. I normally don’t follow tutorials, because it sort of feels like cheating, but I’ll put that aside and follow this one.

P#82087 2020-09-22 04:41

Happy to help! That tutorial is useful as well, because it can be extended later on to enable more complicated features for a nice challenge. Feel free to ask for help! You can get some ideas later on by looking at the work of @Powersaurus on twitter, and I'm also logging my development of something similar with @ValerADHD on twitter.

P#82088 2020-09-22 04:47 ( Edited 2020-09-22 04:47)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-10-24 00:18 | 0.046s | 2097k | Q:52