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.
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.
Hang on,
singl*singl+cosgl*cosgl
should always be one (if mathematically perfect) anyway!
oh, my bad, I’ll fix that and see if it works. I’m really not great at math stuff.
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.
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.
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.
[Please log in to post a comment]