Instead of using the ray length directly, basically it projects the intersection point onto the direction line, and using the distance from that to the origin instead. It does this using vectors and dot products.
You can check with my original implementation of that block. It’s probably correct. I don’t actually know if my block works. It’s never actually used in the project, and it’s just there because at one point i was considering making the sprite dir variable a vector instead of an angle.
Also I noticed that the change variable block doesn’t have hyperblocks support.
I added the ability to elevate up/down. Drawing walls accounting for elevation was quite simple, actually. But in this project there can only be one wall per row, so it works but it doesn't work. I think that can only work with adequate performance with a grid-based map. Don't know how to draw floors/ceilings yet even in a grid-based map, I'll try to figure that one out.
I like how fast this raycaster is, but it isn't really all that easy to use. You can't move left and right just by changing the player's X or Y. There's just a lot of math that isn't really concealed behind a curtain and so you are technically forced to decipher it.
???
Are you talking about the sprite x and sprite y variables? I forgot to delete them. The variable that controls the player position is the "player pos" variable. It's a 2-item list/a vector
I would try to comment my Snap! code if it wasn't such a hassle.
Also I wrote an explanation of what a lot of the math is doing on my post.
I mean, alright. I guess you should maybe push out an update later on to make all the math into a block, just like what @joecooldoo did with his raycaster block (I think it was him?).
I think so, except that it turns counterclockwise instead of clockwise. (That's because the formulas you used are built around math-style angles, ccw from east, rather than orienteering-style angles, cw from north.)
Easiest fix is just use the negative of the angle throughout.