Okay I have run some optimisations on this raycaster and I have removed the bugs and bug-fixes. I am confident that I can get 640 rays working at decent speed, at the moment the frame rate is 170+ when doing nothing 150+ when rotating but only a measly 50+ when walking.
I am trying to avoid casting rays if at all possible for example when the camera is rotating I have scrolled the distance values through the array and only cast rays that will hit new areas of the map. This works perfectly. I am trying to cheat when moving too by simply sliding the rays along the walls and only casting those rays that are near an edge or beyond the visible range. But this has proven to be a royal pain. I know it can be done. But I am constantly running into the same brick wall.
Things I have noted though are walls need to be altered according to the angle of the ray multiplied by direction of travel and not simply the direction the camera is moving at. Sometimes the alterations need to be applied as the cosine other walls require it to be the sine. The first file below does not include the movement cheat the other one does, the problem is in the move_rays() subroutine. I will trade karma for advise. Any suggestions will be appreciated.