// 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(); }
static void Main() { var renderer = new ConsoleRenderer(Rows,Col); var particleOperator = new ParticleUpdater(); var engine = new Engine(renderer,particleOperator,null,300); GenerateParticle(engine); engine.Run(); }
static void Main() { var renderer = new ConsoleRenderer(Rows, Cols); var particleOperator = new ParticleUpdater(); var engine = new Engine(renderer, particleOperator, null, 300); GenerateInitialData(engine); engine.Run(); }
static void Main(string[] args) { var renderer = new ConsoleRenderer(SimulationRows, SimulationCols); var particleOperator = new ParticleUpdater(); var particles = new List<Particle>() { new Particle(new MatrixCoords(5,5), new MatrixCoords(1, 1)), new ParticleEmitter(new MatrixCoords(5,10), new MatrixCoords(0, 0), new Random()) }; var engine = new Engine(renderer, particleOperator, particles); engine.Run(); }
// Create a ChickenParticle class. // The ChickenParticle class moves like a ChaoticParticle, // but randomly stops at different positions for several simulation ticks and, // for each of those stops, creates (lays) a new ChickenParticle. static void Main() { IRenderer renderer = new ConsoleRenderer(MaxRows, MaxCols); IParticleOperator particleOperator = new ParticleUpdater(); int sleepTimeMs = 250; Engine engine = new Engine(renderer, particleOperator, sleepTimeMs); // Create a ChickenParticle (it will spawn other particles) MatrixCoords initialPosition = new MatrixCoords(MaxRows / 2, MaxCols / 2); MatrixCoords initialSpeed = new MatrixCoords(0, 0); Particle chickenParticle = new ChickenParticle(initialPosition, initialSpeed); engine.AddParticle(chickenParticle); SetConsole(); engine.Run(); }