예제 #1
0
        public static void ApplyForceLimits(Sprite sprite, FormStageBase stage)
        {
            if (sprite.VerticalVelocityLimit != 0)
            {
                if (sprite.VerticalVelocity > sprite.VerticalVelocityLimit)
                {
                    sprite.VerticalVelocity = sprite.VerticalVelocityLimit;
                }
                else if ((sprite.VerticalVelocity * -1) > sprite.VerticalVelocityLimit)
                {
                    sprite.VerticalVelocity = sprite.VerticalVelocityLimit * -1;
                }
            }

            if (sprite.HorizontalVelocityLimit != 0)
            {
                if (sprite.HorizontalVelocity > sprite.HorizontalVelocityLimit)
                {
                    sprite.HorizontalVelocity = sprite.HorizontalVelocityLimit;
                }
                else if ((sprite.HorizontalVelocity * -1) > sprite.HorizontalVelocityLimit)
                {
                    sprite.HorizontalVelocity = sprite.HorizontalVelocityLimit * -1;
                }
            }
        }
        public static float GenerateRandomWind(int minValue, int maxValue, FormStageBase stage)
        {
            float  wind;
            Random r = new Random();
            float  f = (float)r.NextDouble();

            wind  = r.Next(minValue, maxValue);
            wind += f;

            if (f > 0.5F)
            {
                wind *= -1;
                stage.WindDirection = "W";
            }
            else
            {
                stage.WindDirection = "E";
            }

            return((float)Math.Round(wind, 2, MidpointRounding.AwayFromZero));
        }
예제 #3
0
 public static void ApplyConstantForce(Sprite sprite, FormStageBase stage)
 {
     sprite.HorizontalVelocity += stage.constHForce;
     sprite.VerticalVelocity   += stage.constVForce;
 }
예제 #4
0
 public static void ApplyDrag(Sprite sprite, FormStageBase stage, Enum.Axis axis)
 {
     ApplyDrag(sprite.Drag + stage.Drag, sprite, axis);
 }