Ejemplo n.º 1
0
        // Speed calculations
        float CalculateSpeedFromKeys(float v, Key accKey, Key deccKey)
        {
            float vChange = Config.CameraMoveSpeedAcc;
            float vDecay  = Config.CameraMoveSpeedDecay;
            float vMax    = Config.CameraMoveSpeedMax;

            if (KeyController.IsKeyDown(accKey) && !KeyController.IsKeyDown(deccKey))
            {
                if (v >= 0)
                {
                    v = Math.Min(v + vChange, vMax);
                }
                else
                {
                    v = Math.Min(v + vDecay + vChange, vMax);
                }
            }
            else if (KeyController.IsKeyDown(deccKey) && !KeyController.IsKeyDown(accKey))
            {
                if (v <= 0)
                {
                    v = Math.Max(v - vChange, -vMax);
                }
                else
                {
                    v = Math.Max(v - vDecay - vChange, -vMax);
                }
            }
            else if (v > 0)
            {
                v = Math.Max(v - vDecay, 0f);
            }
            else
            {
                v = Math.Min(v + vDecay, 0f);
            }
            return(v);
        }