Пример #1
0
 public Caster(char[][] map)
 {
     Map  = map;
     Rays = new CastedRay[Constants.SCREEN_WIDTH + 1];
     for (int i = 0; i <= Constants.SCREEN_WIDTH; i++)
     {
         Rays[i] = new CastedRay();
     }
 }
        protected float CorrectFishEyeEffect(float angle, CastedRay ray)
        {
            if (angle == 33f)
            {
                return(CorrectDistance(ray));
            }

            var halfFOV = (int)Constants.FOV / 2;

            angle = halfFOV - angle;
            var d = CorrectDistance(ray);

            return((float)(Math.Cos(MathHelper.ToRadians(angle)) * d));
        }
        float CorrectDistance(CastedRay ray)
        {
            var d = (float)ray.TranslateVector.Length();

            return(d);
        }