Imagine shooting an arrow, but if one end of the arrow is outside the screen, it stretches the arrow obscenely, obviously not accurately representing the point anymore. This is a fake 3d world after all, such as wolfenstein. The calculation that's taking place for the verticle "z" axis is mearly scaling an arbitrary value.
I haven't found any information that addresses this, but after looking around I'm suspicious that using matrices might be the solution. I'd like to avoid having to learn that or adapt the engine I've already made, especially if that isn't the solution, or the only solution.
Here's some of the code I'm using:
pLoc is the x,y of the camera. mLoc is the x,y of the point. pRot is the rotation of the camera. pHgh is the height (z) of the camera. mHgh is the height (z) of the point.
On the grid, x increases to the right, and y down.
The grid size of the world is 128 pixels, and that's also the max height for the camera.
The screen is 320 by 200 pixels.
xxx = pLoc.x-mLoc.x yyy = pLoc.y-mLoc.y moo = atan(xxx,-yyy)*(180/pi) if moo < 0 then moo = moo+360 tmp = pRot+120-moo if moo < 180 and pRot > 90 then tmp = tmp-360 else if moo > 180 and pRot > 270 then tmp = tmp-360 end if m = sqrt(power(pLoc.x-mLoc.x,2)+power(pLoc.y-mLoc.y,2)) -- distance to point m = m*cos(pRot-moo)*(pi/180) -- eliminates "fisheye" from distance boo = (tmp*-320/60)-160 -- this is x spot on screen. poo = (64-pHgh+mHgh)*(300/(m)) -- this is the y spot. goo = 128/m*2 -- this is a converted distance for whatever.
Again, if the point goes off-screen, its position goes crazy: it's not being represented correctly. If the answer really is that this would work with vector math, that's fine, but if there's any chance to even fake it in this approach, I'd very much like to discover it.