Farai Aschwanden wrote:
Hi
Its as small as impressive. You are using circles for the walls
and wondering why you get the fish eye view? I assume the block
would look better if you use rectangles.
Thanks, I think, but the only circle in there is the one used on
the "map" to mark the player's location. The walls are drawn on the
"3D" side as vertical lines side-by-side.
I thought at first that the distortion was coming from the fact
that if you cast lines at a wall running left and right of you, the
distance traveled by the rays increases to either side, making the
walls seem farther away at the edges than they really are. I tried
correcting for that with the line:
half_apparent_wall_height *= 1.0+ (abs(n-50) * .005)
which slightly lengthens the walls to either side, but that didn't
look right either. I then noticed, once I added the movement code,
that moving or turning left and right didn't change the distortion.
In other words, a patch of wall didn't change its distortion based
on the angle at which it was viewed. So I tried this line on the
theory that distant objects shouldn't "shrink" at the same rate as
distance increased:
half_apparent_wall_height = (fov_size[1] - (dist*1.1))/2.0
But that didn't work either. I suspect the relationship between
apparent size and distance is nonlinear, but don't know what it is.
It's not like I seriously plan to develop this "engine," but if
anybody knows the magic equation, this project could be a fun
little thing to put in the Cookbook.
Kris