I've come here because I can't seem to find out what's wrong with my ray tracer.
I fixed the fish eye effect when looking straight on at walls, but the effect remains when the player is looking at walls to the side.
I think it's because most of the rays hit the surface close to the player, while fewer and fewer rays hit more distant walls, resulting in a curve. The only problem is I don't know how to make it appear linear.
float dist = distance*cos(angle); //fix distorted distance
float rat = (depth-(dis))/depth; //calculate ratio for wall height
float h = 64*rat; //calculate height
PImage slice = sprites[0].get((int)(inter/2),0,1,16); //get image slice
image(slice,i*4,768-h/2,4,h); //display image slice
In this example, the top screen is the raw data while the bottom screen it the ray traced 2.5D image. I've made the rays visible.
Edit: I changes "rat" to be 192/dis. This seems to look a bit better, but is still slightly curved...