Archived

This topic is now archived and is closed to further replies.

RPGeezus

Raycasting (ie Wolfenstein) problem

Recommended Posts

I've been writing a ray caster off and on using some horrible development tools (read no debugger). I cannot change this for the time being. The code works on a grid, just like Wolfenstein, and I cast rays looking for vertical and horizontal intersections. I've run in to a problem where I'm seeing my walls not being drawn like boxes, but instead being draw like this: (overhead view) .----. |.....| |.....| |___|_ ,,,,,,| (please ignore the ') The right and bottom walls seems to be too long! To illustrate the problem, imaging your were looking down a hall way: ie: xxxxxxx -> xxxxxxx What you would see with my engine would be a nice smooth wall to your right, and on the left you would see the smooth wall interupted every wall length by a short perpendicular wall. ie (over head view) xxxxxxxxxxxxxxx ...x......x......x... ..................... xxxxxxxxxxxxxxx Has anybody run in to this problem before? Any help would be appreciated. Will [edited by - RPGeezus on October 20, 2003 4:54:16 PM] [edited by - RPGeezus on October 20, 2003 4:55:05 PM]

Share this post


Link to post
Share on other sites
Your distance-calculation is not correct, or the values for it.

Note that (tileX, tileY), where coords are ints, gives the upper-left corner of a tile. Things will work when you calc the distance to the walls to the right of the view in your pic, because you take the distance between the viewpoint and the upper-most edge of the tile. OTOH, for the left walls, u need to take the distance from the viewpoint "to the lower edge", thus add one tile to Y.

Share this post


Link to post
Share on other sites