For this assignment you will make a animation of particle movement. This common animation is called a "starfield" since it can also be used to simulate movement through a field of stars. Ultimately it is up to you to determine what you want your scene to look like, the big bang? A firework festival (every click causes a new particle array to explode)?
You may find the following resources helpful:
- slides 1-131: OOP--Interfaces, Inheritance & Encapsulation
- Slides 19-25 help with the Math.cos, Math.sin work you will need to perform.
- Slides 26 - 34 should help you to get your normal and oddball particle to move.
- Polymorphism
Your program must use three classes to model particle movement. A "Normal" particle class, an "Oddball" particle class and a "Jumbo" particle class. All the particles must be stored in a single array using an abstract "Particle" class. The Jumbo particle must extend the "Normal" or Oddball class through inheritance.
There will be 4 pde
files that you will work with: Space.pde, Normal.pde,
- Clone this repository.
- First, finish the
Normal
class. It will need the following members:
- 5 member variables:
- X and Y positions, Color, Angle and Speed. (Use doubles for X, Y, Speed and Angle)
Normal()
, 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 - feel free to customize the look of the particle beyond color.
- Now finish the program's
setup()
anddraw()
- Add one
Normal
particle variable, and make sure you can see it move - Now modify the program so you have an array of Normal particles.
- Run your program and make sure you can see all the particles move.
- Finish the Oddball class in Oddball.pde. It should extend the normal class (So add
extends Normal
). - Finish the
Oddball
class. It will be similiar to the Normal particle, but Oddball particles should have differentmove()
andshow()
methods. Perhaps it will zig and zag, or moves in a circular motion. It should also look different. - In your setup, change the way you initialize your array of Normal particles to sometimes create a Normal and sometimes create an Oddball particle. (You can use Math.random and a conditional to randomize how many Oddball particles to create).
- Now, write a new Jumbo class that also
extends Normal
. In this class you will ONLY need to override one method,show()
to draw a larger version of the Normal particle. - You must have at least 1 Jumbo partickle in particles array. Run your program and make sure you can see the Jumbo.
- Finally, make sure you update index.html to include a title and a meaningful summary. The summary should be short technical descriptionn of what Java features the project demonstrates. (I will doc 10% if this is missing.)
Extensions: Have a fun and be creative. If you have extra time you may want to modify your program and add extra features. Experiment with different arrangements of particles. Look at student work from the links below for other variations.
Windows pun
Spiral Galaxy
Particle Collider
Fireworks
Fireworks and boats
Big bang
Warp Drive
80's spiral
Heh so bad
Modulate speed