For this assignment you will make a animation of moving through a starfield. It is very similar to viewing an exploding firework headon as the explosion ejects particles in a 3D sphere. We will do a simulation of this in our project in 2D. You may find slides approximately 13 - 43 on Unit_9a_InheritanceAndEncapsulation presentation helpful.
Your program must use at least two classes to model the particles. A Particle (star) super class and an Oddball (spaceship) sub class. All the particles must be stored in a single array list of the super class type. Make sure you do not unnecessarily duplicate inherited variables and functions in the Oddball sub class. Your Oddball sub class need only contain a constructor and void move() and/or void show() so that the Oddball moves and/or looks different.
- Fork this repository
- First, finish the
Particleclass. It will need the following members:
- 5 member variables: X and Y positions, Color, Angle and Speed. (Hint: use doubles for X, Y, Speed and Angle)
Particle(), the class constructorvoid move(), Takes the cos of the angle times the speed and adds it to the X coordinate. Does the same to Y with the sin of the angle.void show(), draws the particle in the correct color
- Now finish the program's
setup()anddraw() - Add one
Particlevariable, and make sure you can see it move - Add an array list of type
Particleand loop through it to move and show all the Particles. - Create an OddballParticle class that
extendsthe Particle class. - Change a random element in the array to a
OddballParticleinstead of aParticle - Run your program. Make sure you can see the Oddball.
- Submit the url of your working GitHub webpage to google classroom
- Extensions: Do this extension to reach 100% - increase brightness of
Particle()by adding a new propertyalpha. This property needs to be modified based on its distance from the center of the Processing canvas.