Ejemplo n.º 1
0
        public void Start(Snow snow, int firstspace, int space, int flake, int i, int a)
        {
            snow.Position = new Vector();
            snow.Move     = new Vector();


            snow.Move.Y = _random.Next(2, 5);

            snow.Position.X = SPosition(firstspace, space, flake, i);
            snow.Position.Y = SPosition(firstspace, space, flake, i = -a);
        }
Ejemplo n.º 2
0
        public void Test()
        {
            var drav           = new Draving();
            var random         = new Random();
            int width          = random.Next(400, 600);
            int height         = random.Next(200, 300);
            int space          = flakeSize * 3;
            int widthQuantity  = width / space;
            int heightQuantiti = height / space;
            int firstspace     = (space) / 2;
            var snow           = new Snow(random);


            drav.Rect(width, height);

            Snow[,] flakes = new Snow[heightQuantiti, widthQuantity];


            for (int a = 0; a < heightQuantiti; a++)
            {
                for (int i = 0; i < widthQuantity; i++)
                {
                    flakes[a, i] = new Snow();
                    snow.Start(flakes[a, i], firstspace, space, flakeSize, i, a);
                }
            }

            var task = Flurry(widthQuantity, heightQuantiti, snow, flakes, width, height);

            for (; ;)
            {
                var key = Console.ReadKey().Key;

                if (key == ConsoleKey.RightArrow)
                {
                    wind.Strength += 3;
                    if (wind.Strength > 36)
                    {
                        wind.Strength = 36;
                    }
                }
                if (key == ConsoleKey.LeftArrow)
                {
                    wind.Strength -= 3;
                    if (wind.Strength < -36)
                    {
                        wind.Strength = -36;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public async Task Flurry(int quantity, int quantity2, Snow snow, Snow[,] flakes, int width, int height)
 {
     await Task.Run(() =>
     {
         for (; ;)
         {
             //Thread.Sleep(100);
             for (int a = 0; a < quantity2; a++)
             {
                 for (int i = 0; i < quantity; i++)
                 {
                     snow.SMove(flakes[a, i], flakeSize, width, height, wind);
                 }
             }
         }
     }
                    );
 }
Ejemplo n.º 4
0
        public void SMove(Snow snow, int flakeSize, int width, int height, Wind wind)
        {
            //snow.Back = new Vector();
            snow.Back   = snow.Position.CreateCopy();
            snow.Move.X = _random.Next(-2, 2);
            snow.Move.X = snow.Move.X + wind.Strength;

            snow.Position = snow.Position + snow.Move;

            if (snow.Position.Y > snow.Move.Y + 1)
            {
                if (snow.Back.X > 1 && snow.Back.X < width - 1 - flakeSize)
                {
                    draw.DelSnow(snow, flakeSize);
                }

                if (snow.Position.X > 1 && snow.Position.X < width - 1 - flakeSize)
                {
                    draw.DSnow(snow, flakeSize);
                }
                else
                {
                    if (snow.Position.X > width - 1 - flakeSize)
                    {
                        snow.Position.X = (snow.Move.X + snow.Position.X) % width;
                    }
                    else
                    {
                        snow.Position.X = snow.Position.X + width - 1 - flakeSize;
                    }
                }
                if (snow.Position.Y > height - 1 - flakeSize - snow.Move.Y - snow.GroundSnow)
                {
                    snow.Position.Y  = (snow.Position.Y + snow.Move.Y + flakeSize + snow.GroundSnow) % height;
                    snow.GroundSnow += 6 - Convert.ToInt32(snow.Move.Y);
                }
            }
        }
Ejemplo n.º 5
0
        public void DelSnow(Snow snow, int flake)
        {
            var blackBrush = new SolidBrush(Color.Black);

            _graphics.FillEllipse(blackBrush, Convert.ToSingle(snow.Back.X) + xOffset, Convert.ToSingle(snow.Back.Y) + yOffset, flake, flake);
        }
Ejemplo n.º 6
0
        public void DSnow(Snow snow, int flake)
        {
            var whiteBrush = new SolidBrush(Color.White);

            _graphics.FillEllipse(whiteBrush, Convert.ToSingle(snow.Position.X) + xOffset, Convert.ToSingle(snow.Position.Y) + yOffset, flake, flake);
        }