/************************************************************************************
CANADA DAY
By: Liam McAlinden
Its Canada Day, move the mouse to set the location for the Fireworks to
launch and enjoy the show
Intro to Media Computation
October 19th 2016
/////////////////////////////////////////////////////////
Disclaimer, some of the code that is used in this program
have been borrowed from the IMC website folder
Adventures in code fireworks folder
But have been modified to make them my own
the ExplosionTime tab was taken from the IMC website folder adventures in code,
fireworks folder which was copied from Daniel Shiffmans Learning processing.
*************************************************************************************/
//Creates an Array list for the Stars so I can make Multiple to
//avoid drawing 100 stars
Stars [] Galaxy = new Stars [1000];
//Creates an Array list for the fireworks
ArrayList<Fireworks> Explosion = new ArrayList<Fireworks> ();
//Creates gravity so the particles can fall at certain speeds
PVector gravity = new PVector (-0.0001, 0.0001);
int exploisonSize = 100; // how particles I will have in this program
float ExplosionTime=.5;// how long each explosion will be
float ExplosionStartTime;
void setup () {
size (400, 600);
ExplosionStartTime = millis();
// the start time for the explosion
//when the prgram starts
rectMode (CORNER);
ellipseMode (CENTER);
// if the stars that are dran equal less than 1000 more will be drawn until then
for (int i = 0; i < 1000; i++) {
Galaxy[i] = new Stars();
colorMode (HSB, 255);// this code was borrowed form the IMC Website, Adventures in code Firworks Tab
}
}
void draw () {
background (10, 0, 41);
// if the stars that are dran equal less than 1000 more will be drawn until then and prints
// i added print to make sure that it worked
for (int i = 0; i < 1000; i++) {
//println(i);
Galaxy[i].drawStar();
}
//trees there just trees
fill (0, 20, 25);
triangle (0, 300, 30, 450, -20, 450);
triangle (40, 320, 60, 450, 20, 450);
triangle (70, 300, 40, 450, 90, 450);
triangle (110, 320, 140, 450, 90, 450);
triangle (140, 300, 120, 450, 160, 450);
triangle (160, 320, 130, 450, 170, 450);
triangle (180, 320, 160, 450, 200, 450);
triangle (210, 300, 200, 450, 220, 450);
triangle (220, 300, 215, 450, 225, 450);
triangle (250, 330, 230, 450, 270, 450);
triangle (270, 320, 260, 450, 290, 450);
triangle (300, 300, 140, 450, 330, 450);
triangle (320, 300, 30, 450, 330, 450);
triangle (360, 310, 60, 450, 370, 450);
triangle (380, 320, 360, 450, 400, 450);
triangle (400, 340, 140, 450, 450, 450);
//hills
fill (0, 20, 15);
ellipse (0, 380, 230, 100);
ellipse (50, 390, 230, 100);
ellipse (140, 390, 230, 100);
ellipse (340, 390, 230, 100);
//ground
fill (0, 38, 27);
rect (0, 400, 400, 300);
// this is for the particle explosion, and if the start time is less than the explosion time
// it will create the explosion
// this code was borrowed form the IMC Website, Adventures in code Fireworks Tab
if (millis()-ExplosionStartTime>ExplosionTime*1000.) {
// will generate a random colour for the fireworks
color explosionColor = color(random(0, 255), 255, 255);
for (int i=0; i<exploisonSize; i++) {
// wherever the mouse is located that is were the explosions will happen
Explosion.add(new Fireworks(mouseX, mouseY, explosionColor));
}
ExplosionStartTime = millis ();
}
// this code is for the duration of time the explosion lasts
for (int i=Explosion.size ()-1; i>=0; i--) {
Fireworks fireworks = Explosion.get(i);
fireworks.refresh();
if (fireworks.explosionTime.isFinished()) {
Explosion.remove(i);// if the time is up than the explosion is removed
}
}
for (int i=0; i<Explosion.size(); i++) {
Fireworks fireworks = Explosion.get(i);
fireworks.display();
}
}