Project 4.3: Fireworks Extended
Make different types of fireworks with each click
REQUIREMENTS
Create three Particle subclasses with unique behavior
The user creates three different types of particles when they LEFT, CENTER, or RIGHT click on the screen.
Each particle must have three unique elements, one from each of the categories listed below. Projects with less distinct particles will not earn full credit.
You're allowed to reuse the trait of one particle in another, but it won't count as a unique feature twice.
In the list below, difficulty of an option is listed in number of stars on a scale of 1 to 5. It's up to you to figure out how to implement the details - if you're stuck on a complex one, try something simpler to start.
Suggested Particle Traits
(1) Appearance
Color ★
Size ★
Shape / Image ★
(2) Motion
Explosion Force Values ★
Gravity / Wind Values ★
Special Movement Patterns ★ - ★★★★★
Spawns more particles as it moves ★★★★
Rocket from bottom moves up then explodes ★★★★
(3) Special Effect
Flickers / Shimmers ★
Fades over time ★★
Changes size over time ★★
Changes color over time ★★★
Leaves trails ★★★★
Examples
GreenConfetti is a rectangle in shades of green that has a really big burst at the start and flickers.
RainbowFade is a circle in random colors that falls very slowly and both changes size and fades over time.
BottleRocket has an image of a rocket that flies from the bottom of the screen to the mouse and trails fire then explodes making normal basic fireworks.
WavyFall is a circle in shades of gold that falls in a sin curve pattern. It fades over time and leaves trails.
STEP BY STEP
1) Create a Basic Particle Subclass
Make a new tab and give it a name to match you first Particle subclass.
Create the class and a constructor call to the Particle superclass
Example:
class GreenSparkly extends Particle
{
GreenSparkly()
{
super();
}
}
2) Update Your Click Event
Update your mousePressed() method to only create this type of particle on a LEFT click.
Instead of making a generic particle, you'll want to make a BlueSparkly.
Example:
void mousePressed()
{
if(mouseButton == LEFT)
{
for(int i = 0 ; i < 30; i++)
{
particles.add(new GreenSparkly());
}
}
}
At this stage when you run the program, it will still look like basic particles. Test that it runs okay, and we'll change that soon!
3) Make Your Particle Unique
Add code to the constructor and override methods as needed to achieve your goal.
For instance, this class makes all the particles blue instead of rainbow. It changes the green shade every frame to create a shimmer effect.
class GreenSparkly extends Particle
{
GreenSparkly()
{
super();
r = 0;
b = 0;
}
void update()
{
super.update();
g = (int) random(100, 255);
}
}
You should see green shimmering particles now. What else can you do to make this firework unique?
4) Add Sufficient Details To Meet Requirement
Every particle needs a unique appearance, motion, and special effect. The example above needs to add some motion to count for full credit.
5) Add Particle #2 and #3
Repeat the process for two new particles that appear on CENTER and RIGHT clicks.
EXTRA CREDIT
Students can earn up to 10% extra credit by making especially complex and impressive fireworks.
EXAMPLE: RUNNING PROGRAM
Click here to download a running version of the program. <COMING SOON>