Question 3 - Particle systems, inheritance and polymorphism;Back to our own (maybe not super but still quite amazing) universe.;Start from this code:A1_Q3.zip. Make sure you understand the code and add comments wherever they are missing.;3a - Different kinds of particles;Implement three different subclasses of class Particle. For each subclass, override the display() method to make the 3 kinds of particles look and behave differently. For at least one subclass, also override the update() method.;To test your subclasses, change the method createParticle() in ParticleSystem so that the system creates each time a different kind of particle from one of your 3 subclasses (could either be random or sequential).;3b - Wind particle system;Implement a subclass of ParticleSystem. Override the applyForces() method.;The applyForces() method is where you can have a particle system that applies one or many forces to its particles.;Your subclass should apply a wind force to its particles in the applyForces() method. A wind force is represented as a simple PVector that gets applied to all the particles of the system. At each call of applyForces(), the wind should also change its heading (ie. its angle) according to some random pattern. You have to change the heading using trigonometry. Make the wind as believable as possible. Use the randomGaussian() and/or the noise() (Perlin noise) function at least once in your code for controlling the wind.;3c - More particle systems;Now, implement two more subclasses of ParticleSystems (ie. there will be three subclasses of ParticleSystems in total).;For these two subclasses, override the createParticle() method. The createParticle() method will determine the kind of particles generated by the system. By overriding it, the kind of particles that each subclass of ParticleSystem generates will be different. For example, one subclass could generate only red, round-shaped particles will low mass, while another might generate a combination of round-shaped and star-shaped particles with random mass.;Once that is done, override the applyForces() method as well. Your two subclasses can apply any force you want on their particles. They can apply forces on all the particles or a subset of them. The only rule is that you should use at least two different forces that we have seen in The Nature of Code: gravitation, repulsion, friction, drag and spring.
Paper#70379 | Written in 18-Jul-2015Price : $37