Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var renderer = new ConsoleRenderer(Rows, Cols);

            var particleOperator = new AdvancedParticleOperatorWithRepeller();

            var engine = new Engine(renderer, particleOperator, null, 300);

            var chaoticParticle = new ChaoticParticle(new MatrixCoords(20, 20), new MatrixCoords(0, 0), RandomGenerator, 1);

            engine.AddParticle(chaoticParticle);

            var attractor = new ParticleAttractor(new MatrixCoords(15, 15), new MatrixCoords(0, 0), 2);

            engine.AddParticle(attractor);

            var repeller = new ParticleRepeller(new MatrixCoords(20, 15), new MatrixCoords(0, 0), 1, 5);

            engine.AddParticle(repeller);

            engine.AddParticle(new Particle(new MatrixCoords(20, 20), new MatrixCoords(0, 0)));

            var chickenParticle = new ChickenParticle(new MatrixCoords(15, 15), new MatrixCoords(0, 0), RandomGenerator, 3, new MatrixCoords(3, 6));

            engine.AddParticle(chickenParticle);

            //GenerateInitialData(engine);

            engine.Run();
        }
Ejemplo n.º 2
0
        static void GenerateInitialData(Engine engine)
        {
            var emitterPosition = new MatrixCoords(29, 0);
            var emitterSpeed = new MatrixCoords(0, 0);

            var emitter = new ParticleEmitter(emitterPosition, emitterSpeed, randGenerator, 5, 2, GenerateRandomParticle);

            engine.AddParticle(emitter);

            //check attractor
            var attractorPosition = new MatrixCoords(10, 10);

            var attractor = new ParticleAttractor(attractorPosition, new MatrixCoords(0, 0), 1);

            engine.AddParticle(attractor);

            // 02.Test the ChaoticParticle through the ParticleSystemMain class
            // Create chaotic particle and add it to the engine
            var chaoticParticle = new ChaoticParticle(new MatrixCoords(15, 15), new MatrixCoords(1, 1), randGenerator);
            engine.AddParticle(chaoticParticle);

            // 04.Test the ChickenParticle class through the ParcticleSystemMain class.
            var chickenParticle = new ChickenParticle(new MatrixCoords(10, 10), new MatrixCoords(-1, 2), randGenerator, 20);
            engine.AddParticle(chickenParticle);

            // 06.Test the ParticleRepeller class through the ParticleSystemMain class
            // create repeller with large radius and power to see the result
            // because in one moment there are too many new chicken particles created
            var particleRepeller = new ParticleRepeller(new MatrixCoords(20, 20), new MatrixCoords(0, 0), 10, 20.0);
            engine.AddParticle(particleRepeller);
        }
Ejemplo n.º 3
0
 private static bool IsInRange(Particle particle, ParticleRepeller repeller)
 {
     return(particle.Position.Row > repeller.Position.Row - repeller.RepulsionRadius &&
            particle.Position.Row < repeller.Position.Row + repeller.RepulsionRadius &&
            particle.Position.Col > repeller.Position.Col - repeller.RepulsionRadius &&
            particle.Position.Col < repeller.Position.Col + repeller.RepulsionRadius);
 }
Ejemplo n.º 4
0
        static void GenerateInitialData(Engine engine)
        {
            var emitterPosition = new MatrixCoords(29, 0);
            var emitterSpeed    = new MatrixCoords(0, 0);

            var emitter = new ParticleEmitter(emitterPosition, emitterSpeed, randGenerator, 5, 2, GenerateRandomParticle);

            engine.AddParticle(emitter);

            //check attractor
            var attractorPosition = new MatrixCoords(10, 10);

            var attractor = new ParticleAttractor(attractorPosition, new MatrixCoords(0, 0), 1);

            engine.AddParticle(attractor);

            // 02.Test the ChaoticParticle through the ParticleSystemMain class
            // Create chaotic particle and add it to the engine
            var chaoticParticle = new ChaoticParticle(new MatrixCoords(15, 15), new MatrixCoords(1, 1), randGenerator);

            engine.AddParticle(chaoticParticle);

            // 04.Test the ChickenParticle class through the ParcticleSystemMain class.
            var chickenParticle = new ChickenParticle(new MatrixCoords(10, 10), new MatrixCoords(-1, 2), randGenerator, 20);

            engine.AddParticle(chickenParticle);

            // 06.Test the ParticleRepeller class through the ParticleSystemMain class
            // create repeller with large radius and power to see the result
            // because in one moment there are too many new chicken particles created
            var particleRepeller = new ParticleRepeller(new MatrixCoords(20, 20), new MatrixCoords(0, 0), 10, 20.0);

            engine.AddParticle(particleRepeller);
        }
 private static bool IsInRange(Particle particle, ParticleRepeller repeller)
 {
     return particle.Position.Row > repeller.Position.Row - repeller.RepulsionRadius
            && particle.Position.Row < repeller.Position.Row + repeller.RepulsionRadius
            && particle.Position.Col > repeller.Position.Col - repeller.RepulsionRadius
            && particle.Position.Col < repeller.Position.Col + repeller.RepulsionRadius;
 }
Ejemplo n.º 6
0
        // Implement a ParticleRepeller class. A ParticleRepeller is a Particle, which pushes other particles away from it
        // (i.e. accelerates them in a direction, opposite of the direction in which the repeller is).
        // The repeller has an effect only on particles within a certain radius (see Euclidean distance).
        static void Main()
        {
            IRenderer renderer = new ConsoleRenderer(MaxRows, MaxCols);
            IParticleOperator particleOperator = new ParticleUpdater();

            // Add particle repeller (appears as 'R' on the console)
            MatrixCoords repellerPosition = new MatrixCoords(MaxRows * 2 / 4, MaxCols * 2 / 4);
            MatrixCoords repellerSpeed = new MatrixCoords(0, 0);
            int repellerGravity = -4; // negative for antigravity
            ParticleRepeller repeller = new ParticleRepeller(repellerPosition, repellerSpeed, repellerGravity);

            // Use a field engine - derives from Engine, but can affect the speed of the particles,
            // the center of the field is the repeller

            int sleepTimeMs = 50;
            FieldEngine engine = new FieldEngine(renderer, particleOperator, sleepTimeMs, repeller);
            engine.AddParticle(repeller);

            // Add emmitter for free particles (appears as 'E' on the console)
            MatrixCoords emitterPosition = new MatrixCoords(MaxRows / 4, MaxCols / 4);
            MatrixCoords emitterSpeed = new MatrixCoords(4, 4);
            int particleLifeTicks = 30;
            ParticleEmitter emitter = new ParticleEmitter(emitterPosition, emitterSpeed, particleLifeTicks);
            engine.AddParticle(emitter);

            SetConsole();
            engine.Run();
        }
Ejemplo n.º 7
0
 private static int DecreaseVectorCoordToPower(ParticleRepeller repeller, int rToParticleCoord)
 {
     if (Math.Abs(rToParticleCoord) > repeller.RepulsiveForce)
     {
         rToParticleCoord = (rToParticleCoord / (int)Math.Abs(rToParticleCoord)) * repeller.RepulsiveForce;
     }
     return(rToParticleCoord);
 }
 private static int DecreaseVectorCoordToPower(ParticleRepeller repeller, int pToRepCoord)
 {
     if (pToRepCoord != 0 && Math.Abs(pToRepCoord) > repeller.RepelPower)
     {
         pToRepCoord = (pToRepCoord / (int)Math.Abs(pToRepCoord)) * repeller.RepelPower;
     }
     return pToRepCoord;
 }
 private static int DecreaseVectorCoordToPower(ParticleRepeller repeller, int pToAttrCoord)
 {
     if (Math.Abs(pToAttrCoord) > repeller.PushPower)
     {
         pToAttrCoord = (pToAttrCoord / (int)Math.Abs(pToAttrCoord)) * repeller.PushPower;
     }
     return pToAttrCoord;
 }
 private static int DecreaseVectorCoordToPower(ParticleRepeller repeller, int pToRepCoord)
 {
     if (pToRepCoord != 0 && Math.Abs(pToRepCoord) > repeller.RepelPower)
     {
         pToRepCoord = (pToRepCoord / (int)Math.Abs(pToRepCoord)) * repeller.RepelPower;
     }
     return(pToRepCoord);
 }
Ejemplo n.º 11
0
        private bool IsParticleInRadius(Particle particle, ParticleRepeller repeller)
        {
            if (particle.Position.Row > repeller.Position.Row - repeller.RepelRadius &&
                particle.Position.Row < repeller.Position.Row + repeller.RepelRadius &&
                particle.Position.Col > repeller.Position.Col - repeller.RepelRadius &&
                particle.Position.Col < repeller.Position.Col + repeller.RepelRadius)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 12
0
        private static MatrixCoords GetAccelerationFromParticleAwayToReppeler(ParticleRepeller repeler, Particle particle)
        {
            var currParticleToReppelerVector = particle.Position - repeler.Position;

            int ptoReppRow = currParticleToReppelerVector.Row;
            ptoReppRow = DecreaseVectorCoordToPower(repeler, ptoReppRow);

            int ptoReppCol = currParticleToReppelerVector.Col;
            ptoReppCol = DecreaseVectorCoordToPower(repeler, ptoReppCol);

            var currAcceleration = new MatrixCoords(ptoReppRow, ptoReppCol);
            return currAcceleration;
        }
Ejemplo n.º 13
0
        private static MatrixCoords GetAccelerationFromRepellerToParticle(ParticleRepeller repeller, Particle particle)
        {
            var currParticleToAttractorVector = repeller.Position - particle.Position;

            int pToAttrRow = currParticleToAttractorVector.Row;

            pToAttrRow = DecreaseVectorCoordToPower(repeller, pToAttrRow);

            int pToAttrCol = currParticleToAttractorVector.Col;

            pToAttrCol = DecreaseVectorCoordToPower(repeller, pToAttrCol);

            var currAcceleration = new MatrixCoords(-pToAttrRow, -pToAttrCol);

            return(currAcceleration);
        }
        private void Reppel(Particle particle, ParticleRepeller repeller)
        {
            var yDirection = repeller.RepulsionPower;
            var xDirection = repeller.RepulsionPower;

            if (particle.Position.Row - repeller.Position.Row < 0)
            {
                yDirection = -yDirection;
            }

            if (particle.Position.Col - repeller.Position.Col < 0)
            {
                xDirection = -xDirection;
            }

            particle.Accelerate(new MatrixCoords(yDirection, xDirection));
        }
Ejemplo n.º 15
0
        private MatrixCoords GetAccelerationFromParticleToRepeller(ParticleRepeller repeller, Particle particle)
        {
            var currParticleToRepellerVector = repeller.Position - particle.Position;
            var currAcceleration = new MatrixCoords();


            int pToRepRow = currParticleToRepellerVector.Row;
            pToRepRow = -DecreaseVectorCoordToPower(repeller, pToRepRow);

            int pToRepCol = currParticleToRepellerVector.Col;
            pToRepCol = -DecreaseVectorCoordToPower(repeller, pToRepCol);

            currAcceleration = new MatrixCoords(pToRepRow, pToRepCol);


            return currAcceleration;
        }
Ejemplo n.º 16
0
        private void Reppel(Particle particle, ParticleRepeller repeller)
        {
            var yDirection = repeller.RepulsionPower;
            var xDirection = repeller.RepulsionPower;

            if (particle.Position.Row - repeller.Position.Row < 0)
            {
                yDirection = -yDirection;
            }

            if (particle.Position.Col - repeller.Position.Col < 0)
            {
                xDirection = -xDirection;
            }

            particle.Accelerate(new MatrixCoords(yDirection, xDirection));
        }
Ejemplo n.º 17
0
        private MatrixCoords GetAccelerationFromParticleToRepeller(ParticleRepeller repeller, Particle particle)
        {
            var currParticleToRepellerVector = repeller.Position - particle.Position;
            var currAcceleration             = new MatrixCoords();


            int pToRepRow = currParticleToRepellerVector.Row;

            pToRepRow = -DecreaseVectorCoordToPower(repeller, pToRepRow);

            int pToRepCol = currParticleToRepellerVector.Col;

            pToRepCol = -DecreaseVectorCoordToPower(repeller, pToRepCol);

            currAcceleration = new MatrixCoords(pToRepRow, pToRepCol);


            return(currAcceleration);
        }
        public override void TickEnded()
        {
            foreach (var attractor in this.attractors)
            {
                foreach (var particle in this.particles)
                {
                    var currAcceleration = GetAccelerationFromParticleToAttractor(attractor, particle);
                    ParticleRepeller pr  = attractor as ParticleRepeller;
                    if (pr != null && Distance(pr, particle) <= pr.RepellerRadius)
                    {
                        currAcceleration = new MatrixCoords(-currAcceleration.Row, -currAcceleration.Col);
                    }

                    particle.Accelerate(currAcceleration);
                }
            }

            this.attractors.Clear();
            this.particles.Clear();
        }
Ejemplo n.º 19
0
        private static void GenerateInitialData(Engine engine)
        {
            engine.AddParticle(
                new Particle(
                    new MatrixCoords(10, 10),
                    new MatrixCoords(0, 0))
                );

            engine.AddParticle(
                new DyingParticle(
                    new MatrixCoords(20, 30),
                    new MatrixCoords(-1, 1), 8)
                );

            var emitterPosition = new MatrixCoords(29, 0);
            var emitterSpeed    = new MatrixCoords(0, 0);
            var emitter         = new ParticleEmitter(emitterPosition, emitterSpeed, RandomGenerator, 5, 2, GenerateRandomParticle);

            //engine.AddParticle(emitter);

            var attractorPosition = new MatrixCoords(15, 15);
            var attractor         = new ParticleAttractor(attractorPosition, new MatrixCoords(0, 0), 1);

            engine.AddParticle(attractor);

            var repellerPosition = new MatrixCoords(15, 25);
            var repeller         = new ParticleRepeller(repellerPosition, new MatrixCoords(0, 0), 3, 10);

            engine.AddParticle(repeller);

            //engine.AddParticle(
            //    new ChickenParticle(
            //        new MatrixCoords(10, 10),
            //        new MatrixCoords(0, 0), RandomGenerator, 2)
            //    );
        }
        // Check if given particle is in the range(radius) of the repeller
        // Using "Euclidean distance" formula to calculate the distance between the two particles
        private bool IsInRange(MatrixCoords subtractedCoords, ParticleRepeller repeller)
        {
            int range = subtractedCoords.Col * subtractedCoords.Col + subtractedCoords.Row * subtractedCoords.Row;

            return(range <= repeller.RepellerRadius * repeller.RepellerRadius);
        }
Ejemplo n.º 21
0
        private static void GenerateInitialData(Engine engine)
        {
            /*engine.AddParticle(
                new Particle(
                    new MatrixCoords(0, 8),
                    new MatrixCoords(-1, 0))
                );

            engine.AddParticle(
                new DyingParticle(
                    new MatrixCoords(20, 5),
                    new MatrixCoords(-1, 1),
                    12)
                );*/

            // Test the ChaoticParticle.
            var chaoticParticle = new ChaoticParticle(
                    new MatrixCoords(20, 25),
                    new MatrixCoords(-1, 1),
                    RandomGenerator);
            engine.AddParticle(chaoticParticle);

            // Test the ChickenParticle.
            var chickenParticle = new ChickenParticle(
                new MatrixCoords(25, 15),
                new MatrixCoords(0, 1),
                RandomGenerator);
            engine.AddParticle(chickenParticle);

            // Test the ParticleRepeller.
            var particleRepeller = new ParticleRepeller(
                new MatrixCoords(10, 13),
                new MatrixCoords(0, 0),
                2, 10);

            engine.AddParticle(particleRepeller);

            var emitterPosition = new MatrixCoords(19, 15);
            var emitterSpeed = new MatrixCoords(0, 0);
            var emitter = new ParticleEmitter(emitterPosition, emitterSpeed,
                RandomGenerator,
                5,
                2,
                GenerateRandomParticle
                );

            engine.AddParticle(emitter);
            
            var attractorPosition = new MatrixCoords(10, 3);
            var attractor = new ParticleAttractor(
                attractorPosition,
                new MatrixCoords(0, 0),
                1);

            var attractorPosition2 = new MatrixCoords(10, 13);
            var attractor2 = new ParticleAttractor(
                attractorPosition2,
                new MatrixCoords(0, 0),
                3);

            // engine.AddParticle(attractor);
            // engine.AddParticle(attractor2);
        }
Ejemplo n.º 22
0
        private static void GenerateInitialData(Engine engine)
        {
            /*engine.AddParticle(
             *  new Particle(
             *      new MatrixCoords(0, 8),
             *      new MatrixCoords(-1, 0))
             *  );
             *
             * engine.AddParticle(
             *  new DyingParticle(
             *      new MatrixCoords(20, 5),
             *      new MatrixCoords(-1, 1),
             *      12)
             *  );*/

            // Test the ChaoticParticle.
            var chaoticParticle = new ChaoticParticle(
                new MatrixCoords(20, 25),
                new MatrixCoords(-1, 1),
                RandomGenerator);

            engine.AddParticle(chaoticParticle);

            // Test the ChickenParticle.
            var chickenParticle = new ChickenParticle(
                new MatrixCoords(25, 15),
                new MatrixCoords(0, 1),
                RandomGenerator);

            engine.AddParticle(chickenParticle);

            // Test the ParticleRepeller.
            var particleRepeller = new ParticleRepeller(
                new MatrixCoords(10, 13),
                new MatrixCoords(0, 0),
                2, 10);

            engine.AddParticle(particleRepeller);

            var emitterPosition = new MatrixCoords(19, 15);
            var emitterSpeed    = new MatrixCoords(0, 0);
            var emitter         = new ParticleEmitter(emitterPosition, emitterSpeed,
                                                      RandomGenerator,
                                                      5,
                                                      2,
                                                      GenerateRandomParticle
                                                      );

            engine.AddParticle(emitter);

            var attractorPosition = new MatrixCoords(10, 3);
            var attractor         = new ParticleAttractor(
                attractorPosition,
                new MatrixCoords(0, 0),
                1);

            var attractorPosition2 = new MatrixCoords(10, 13);
            var attractor2         = new ParticleAttractor(
                attractorPosition2,
                new MatrixCoords(0, 0),
                3);

            // engine.AddParticle(attractor);
            // engine.AddParticle(attractor2);
        }
Ejemplo n.º 23
0
        private static void GenerateInitialData(Engine engine)
        {
            engine.AddParticle(
                new Particle(
                    new MatrixCoords(0, 10),
                    new MatrixCoords(1, 1))
                );

            var emitterPosition = new MatrixCoords(29, 0);
            var emitterSpeed = new MatrixCoords(0, 0);
            var emitter = new ParticleEmitter(emitterPosition, emitterSpeed,
                rand,
                5,
                2,
                GenerateRandomParticle
                );

            engine.AddParticle(emitter);

            var emitterPosition2 = new MatrixCoords(2, 10);
            var emitterSpeed2 = new MatrixCoords(10, 5);
            var emitter2 = new ParticleEmitter(emitterPosition2, emitterSpeed2,
                rand,
                5,
                2,
                GenerateRandomParticle
                );

            engine.AddParticle(emitter2);

            var emitterPosition3 = new MatrixCoords(15, 0);
            var emitterSpeed3 = new MatrixCoords(0, 0);
            var emitter3 = new ParticleEmitter(emitterPosition3, emitterSpeed3,
                rand,
                5,
                2,
                GenerateRandomParticle
                );

            engine.AddParticle(emitter3);

            var attractorPosition = new MatrixCoords(10, 3);
            var attractor = new ParticleAttractor(
                attractorPosition,
                new MatrixCoords(0, 0),
                1);

            var attractorPosition2 = new MatrixCoords(10, 13);
            var attractor2 = new ParticleAttractor(
                attractorPosition2,
                new MatrixCoords(0, 0),
                3);

            engine.AddParticle(attractor);
            engine.AddParticle(attractor2);

            var chaoticParticle = new ChaoticParticle(new MatrixCoords(15, 15), new MatrixCoords(1, 1), rand, 50, 50);
            //engine.AddParticle(chaoticParticle);

            var chickenParticle = new ChickenParticle(new MatrixCoords(15, 15), new MatrixCoords(1, 1), rand, 50, 50,
                20, 10);
            //engine.AddParticle(chickenParticle);

            var repellerParticle = new ParticleRepeller(new MatrixCoords(15, 15), new MatrixCoords(0, 0), 1, 8);
            //engine.AddParticle(repellerParticle);
        }
Ejemplo n.º 24
0
 public FieldEngine(IRenderer renderer, IParticleOperator particleOperator, int sleepTimeMs, ParticleRepeller repeller, List<Particle> particles = null)
     : base(renderer, particleOperator, sleepTimeMs, particles)
 {
     this.repeller = repeller;
 }
        // Check if given particle is in the range(radius) of the repeller
        // Using "Euclidean distance" formula to calculate the distance between the two particles
        private bool IsInRange(MatrixCoords subtractedCoords, ParticleRepeller repeller)
        {
            int range = subtractedCoords.Col * subtractedCoords.Col + subtractedCoords.Row * subtractedCoords.Row;

            return range <= repeller.RepellerRadius * repeller.RepellerRadius;
        }
Ejemplo n.º 26
0
        private static void GenerateInitialData(Engine engine)
        {
            engine.AddParticle(
                new Particle(
                    new MatrixCoords(0, 10),
                    new MatrixCoords(1, 1))
                );

            /*engine.AddParticle(
             * new DyingParticle(
             * new MatrixCoords(20, 5),
             * new MatrixCoords(-1, 1),
             * 12)
             * ); */

            var emitterPosition = new MatrixCoords(29, 0);
            var emitterSpeed    = new MatrixCoords(0, 0);
            var emitter         = new ParticleEmitter(emitterPosition, emitterSpeed,
                                                      RandomGenerator,
                                                      5,
                                                      2,
                                                      GenerateRandomParticle
                                                      );

            engine.AddParticle(emitter);

            var emitterPosition2 = new MatrixCoords(0, 0);
            var emitterSpeed2    = new MatrixCoords(0, 0);
            var emitter2         = new ParticleEmitter(emitterPosition2, emitterSpeed2,
                                                       RandomGenerator,
                                                       5,
                                                       2,
                                                       GenerateRandomParticle
                                                       );

            engine.AddParticle(emitter2);

            var emitterPosition3 = new MatrixCoords(15, 0);
            var emitterSpeed3    = new MatrixCoords(0, 0);
            var emitter3         = new ParticleEmitter(emitterPosition3, emitterSpeed3,
                                                       RandomGenerator,
                                                       5,
                                                       2,
                                                       GenerateRandomParticle
                                                       );

            engine.AddParticle(emitter3);

            var attractorPosition = new MatrixCoords(10, 3);
            var attractor         = new ParticleAttractor(
                attractorPosition,
                new MatrixCoords(0, 0),
                1);

            var attractorPosition2 = new MatrixCoords(10, 13);
            var attractor2         = new ParticleAttractor(
                attractorPosition2,
                new MatrixCoords(0, 0),
                3);

            //engine.AddParticle(attractor);
            //engine.AddParticle(attractor2);

            var chaoticParticle = new ChaoticParticle(new MatrixCoords(15, 15), new MatrixCoords(1, 1), RandomGenerator, 50, 50);
            //engine.AddParticle(chaoticParticle);

            var chickenParticle = new ChickenParticle(new MatrixCoords(15, 15), new MatrixCoords(1, 1), RandomGenerator, 50, 50,
                                                      20, 10);
            //engine.AddParticle(chickenParticle);

            var repellerParticle = new ParticleRepeller(new MatrixCoords(15, 15), new MatrixCoords(0, 0), 1, 8);

            engine.AddParticle(repellerParticle);
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            var renderer = new ConsoleRenderer(Rows, Cols);

            var particleOperator = new AdvancedParticleOperatorWithRepeller();

            var engine = new Engine(renderer, particleOperator, null, 300);

            var chaoticParticle = new ChaoticParticle(new MatrixCoords(20, 20), new MatrixCoords(0, 0), RandomGenerator, 1);
            engine.AddParticle(chaoticParticle);

            var attractor = new ParticleAttractor(new MatrixCoords(15, 15), new MatrixCoords(0, 0), 2);
            engine.AddParticle(attractor);

            var repeller = new ParticleRepeller(new MatrixCoords(20, 15), new MatrixCoords(0, 0), 1, 5);
            engine.AddParticle(repeller);

            engine.AddParticle(new Particle(new MatrixCoords(20, 20), new MatrixCoords(0, 0)));

            var chickenParticle = new ChickenParticle(new MatrixCoords(15, 15), new MatrixCoords(0, 0), RandomGenerator, 3, new MatrixCoords(3, 6));
            engine.AddParticle(chickenParticle);

            //GenerateInitialData(engine);

            engine.Run();
        }
Ejemplo n.º 28
0
        private static void GenerateInitialData(Engine engine)
        {
            engine.AddParticle(
               new DyingParticle(
                   new MatrixCoords(20, 5),
                   new MatrixCoords(-1, 1),
                   12)
               );

            ////Particle Emitter
            var emitterPosition = new MatrixCoords(29, 0);
            var emitterSpeed = new MatrixCoords(0, 0);
            var emitter = new ParticleEmitter(emitterPosition, emitterSpeed,
                RandomGenerator,
                5,
                2,
                GenerateRandomParticle
                );

            //engine.AddParticle(emitter);

            //// Paritcle Attractor
            var attractorPosition = new MatrixCoords(15, 20);
            var attractor = new ParticleAttractor(
                attractorPosition,
                new MatrixCoords(0, 0),
            3);
            //engine.AddParticle(attractor);

            //// IMPORTANT!
            //// Exercises 1 and 2 ->
            //// check classes: ChaoticParticle, AdvancedParticalUpdater
            var crazyPosition = new MatrixCoords(15, 12);
            var crazy = new ChaoticParticle(crazyPosition,
                new MatrixCoords(0, 0),
                RandomGenerator,
                1);

            var crazyPositiontoo = new MatrixCoords(15, 15);
            var crazytoo = new ChaoticParticle(crazyPositiontoo,
                new MatrixCoords(0, 0),
                RandomGenerator,
                1);

            var crazyPositionmore = new MatrixCoords(15, 19);
            var crazymore = new ChaoticParticle(crazyPositionmore,
                new MatrixCoords(0, 0),
                RandomGenerator,
                1);

            engine.AddParticle(crazy);
            engine.AddParticle(crazytoo);
            engine.AddParticle(crazymore);

            //// IMPORTANT!
            //// Exercises 3 and 4 ->
            //// check classes: ChickenParticle, AdvancedParticalUpdater
            var chickenPosition = new MatrixCoords(15, 12);
            var chcken = new ChickenParticle(chickenPosition,
                new MatrixCoords(0, 0),
                RandomGenerator,
                1,
                4);

            engine.AddParticle(chcken);

            //// IMPORTANT!
            //// Exercises 5 and 6 ->
            //// check classes: ParticleEmitter, AdvancedParticalUpdater
            var reppelerPosition = new MatrixCoords(18, 28);
            var reppeler = new ParticleRepeller(
                reppelerPosition,
                new MatrixCoords(0, 0),
                3);

            //engine.AddParticle(reppeler);
        }